Selenium Element Selectors - I thought xPath was slowest?

后端 未结 1 1717
南笙
南笙 2020-12-30 09:41

I ran some tests against a public website to see if I could find differences in the performance of a few different Selenium CSS selectors. I ran one hub with five nodes; ma

相关标签:
1条回答
  • 2020-12-30 10:16

    People seem to lazily assume Xpath is slow and should be avoided. When I interview people I cringe when they say they avoid Xpath because it is slow and brittle. The speed, as shown here, is no longer a concern, and xpath is only as brittle as the person who wrote it. In the right scenario Xpath is awesome and can actually improve performance as it allows you to perform in one command that may have taken several (e.g find element then iterate through sub elements can be performed in one xpath)

    Oh, and dont get me started on people who think there is only one Xpath for an element and that it is found by right clicking in firebug

    0 讨论(0)
提交回复
热议问题