Why one should prefer using CSS over XPath in IE?

后端 未结 4 482
再見小時候
再見小時候 2020-12-03 02:18

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. W

4条回答
  •  清歌不尽
    2020-12-03 02:55

    The biggest reason for suggesting CSS selectors over XPath in IE is performance. IE does not provide a native XPath-over-HTML option as does Firefox and Chrome. It does, however, provide a native CSS selector engine, which will always be faster than the JavaScript-only XPath engine implementation used in the IE driver. And the performance comparison isn't even close. I've seen it measured as much as an order of magnitude slower for XPath locators than CSS selectors (though I can't find the citation at the moment). This is particularly true in versions of IE before 9, where the IE JavaScript engine was vastly slower than the Chakra JavaScript engine introduced in 32-bit IE9.

提交回复
热议问题