<<Previous Post << Complete Tutorial>> Next Post>>
In the previous articles, I have practically demonstrated or explained various articles on Locators, XPath Expressions and CSS Selectors in detail.
In this article, I am going to explain why XPath Expressions are more powerful over CSS Selectors.
Selenium Locators – XPath Expressions are powerful than CSS Selectors
Out of all the different types of locators available, XPath Expressions are the powerful locators for locating different UI elements on the web pages.
XPath Expressions are powerful, as they can locate what other locators cannot locate.
As it is always not possible to locate the UI elements using id, name, class name, link text, etc., we generally go for XPath Expressions and CSS Selectors for the final help.
Coming to the CSS Selectors, they can only traverse forward using the following sibling techniques, but they have no mechanism to traverse to the parent or grandparent nodes.
In the case of XPath Expressions, we can use the XPath Axes mechanism to traverse backward and forward for locating the UI elements on the web page which are generally difficult to locate directly.
Hence XPath Expressions can locate almost all UI elements on the web pages and hence are powerful out of all the other different locators.
In the next article, I will explain why CSS Selectors have higher priority over XPath Expressions.
Next Steps:
- > To learn more about Selenium, continue to the next post (Click on Next Post link below)
- > Check complete Selenium Tutorial Contents here (Click here)
Please leave your questions/comments/feedback below.
Happy Learning ?
On a mission to contribute to the Software Testing Community in all possible ways.
<<Previous Post << Complete Tutorial>> Next Post>>