为什么我们不用CSS 取而代之的是 Xpath

  • As a conclusion here:
    Css selector is not suitable in Touch for following reasons:
    • Time spent almost same with Xpath when excution test case
    • Some Dom structure with text inside cannot be located by Css, and need to get a list of the element, and compared with each element until get the exactly one, then do some operations to the element.

When writing xpath as locator, try to avoid using sibling related locator.
according to a benchmark test in: http://elementalselenium.com/tips/34-xpath-vs-css-revisited-2

But we still may take a look at cssSelector syntax
https://www.w3schools.com/cssref/css_selectors.asp


Tried with Contact_001_AddFirstNameInContact, same test step, and same execution env

  • Xpath : 3'10s average
  • CssSelector : 3'9s average

猜你喜欢

转载自blog.csdn.net/dishe/article/details/69524751