为什么一个人应该喜欢使用CSS在XPath的IE? [英] Why one should prefer using CSS over XPath in IE?
问题描述
我正在开发一个只与IE7和IE8兼容的应用程序。我不知道为什么,但一些建议使用CSS over XPath,而识别IE中的元素。当我访问官方Selenium网站。我阅读了邮件
WebDriver尽可能使用浏览器的本机XPath功能。在没有本机XPath支持的浏览器上,我们提供了自己的实现。这可能会导致一些意想不到的行为,除非你知道各种xpath引擎的差异。
我想知道我在哪里可以找到各种xpath引擎的差异,在哪些情况下,我应该使用CSS和如果我使用IE,在其中XPath具体。感谢。
根据Ashley Wilson的 sauce from sauce labs :
优惠::
- 速度更快
- >没有自下而上的导航。 XPath有
elem\..\another_elem
- 是否注入了Sizzle?或者使用浏览器的CSS定位器解析器?取决于浏览器,并且存在不一致之处。
- They’re faster
- They’re more readable
- CSS is jQuery’s locating strategy
- No one else uses XPATH anyways!
- No "bottom up" navigation. XPath has
elem\..\another_elem
- Is Sizzle injected? Or Browser's CSS locator parser is used? Depends on the browser, and there are inconsistencies.
>
这有点过时,但这里有数字:
我个人认为(2)
I am working on an application which is compatible only with IE7 and IE8. I didn't know why but some suggested to use CSS over XPath while identifying the elements in IE. When I visited the official Selenium site. I read the message
WebDriver uses a browser’s native XPath capabilities wherever possible. On those browsers that don’t have native XPath support, we have provided our own implementation. This can lead to some unexpected behaviour unless you are aware of the differences in the various xpath engines.
I would like to know where I can find the differences in the various xpath engines and in which situations I should use CSS and and in which XPath specifically if I'm using IE. Thanks.
According to Ashley Wilson's report from sauce labs:
Pros:
It's a bit outdated, however here are the numbers:
Personally, I would argue about (2)-nd statement, I must agree with the rest.
Cons:
这篇关于为什么一个人应该喜欢使用CSS在XPath的IE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!