为什么一个人应该喜欢使用CSS在XPath的IE? [英] Why one should prefer using CSS over XPath in IE?

查看:195
本文介绍了为什么一个人应该喜欢使用CSS在XPath的IE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个只与IE7和IE8兼容的应用程序。我不知道为什么,但一些建议使用CSS over XPath,而识别IE中的元素。当我访问官方Selenium网站。我阅读了邮件


WebDriver尽可能使用浏览器的本机XPath功能。在没有本机XPath支持的浏览器上,我们提供了自己的实现。这可能会导致一些意想不到的行为,除非你知道各种xpath引擎的差异。


我想知道我在哪里可以找到各种xpath引擎的差异,在哪些情况下,我应该使用CSS和如果我使用IE,在其中XPath具体。感谢。

解决方案

根据Ashley Wilson的 sauce from sauce labs



优惠::


  1. 速度更快





  2. >

    这有点过时,但这里有数字:





    我个人认为(2)


    1. >没有自下而上的导航。 XPath有 elem\..\another_elem

    2. 是否注入了Sizzle?或者使用浏览器的CSS定位器解析器?取决于浏览器,并且存在不一致之处。


    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:

    1. They’re faster
    2. They’re more readable
    3. CSS is jQuery’s locating strategy
    4. No one else uses XPATH anyways!

    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:

    1. No "bottom up" navigation. XPath has elem\..\another_elem
    2. Is Sizzle injected? Or Browser's CSS locator parser is used? Depends on the browser, and there are inconsistencies.

    这篇关于为什么一个人应该喜欢使用CSS在XPath的IE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆