joao-carloto / FireRobot

Firefox extension for Robot Framework/Selenium.
Other
28 stars 6 forks source link

Generate CSS locators #21

Closed joao-carloto closed 9 years ago

joao-carloto commented 9 years ago

Most experts favor CSS over XPath, however, this is still mater for debate (http://elementalselenium.com/tips/34-xpath-vs-css-revisited-2). The option should be made available.

joao-carloto commented 9 years ago

Some thoughts on this issue:

What will then be the best strategy to build CSS locators automatically? Some examples from people who work with them, on a regular basis, would be useful.

Contributions to this issue are welcome.

joao-carloto commented 9 years ago

I'm holding off this feature for the following reasons:

  1. The use of CSS as a locator could assume many forms, but several would be redundant with the already available locators (id, name, href, src, etc).
  2. Referencing the class might be useful, however in many situations it would be difficult to make the locator unique. There's no direct equivalent to '[x]' (index) from XPath in CSS. Things like ':nth-of-type' work in a parent-child context and it would be difficult to make an algorithm to make locators unique in many situations.
  3. Reference to text is not available in Selenium Web Driver, since the contains() pseudo-class was deprecated (I heard it works on Selenium IDE).
  4. The often advertised advantages of CSS over XPath seem to be inaccurate or at least exaggerated (see http://elementalselenium.com/tips/34-xpath-vs-css-revisited-2).