How to write Dynamic XPath in Selenium

Hi All,

Welcome to Selenium tutorial, today we will see how to write Dynamic Xpath in Selenium because we can’t go ahead without xpath in details.`

We have two awesome plugins,which actually help you write xpath. Please check out below two plugin

Firefox Plugin XPath Generating tool

Chrome XPath Plugin  

Once you are done with xpath I will highly recommend you to visit Dynamic CSS as well which is highly used in Cross-browser Testing as well.


Here is the Youtube video for Dynamic XPath




Relative XPath method


Using single attribute

And so on.

Dynamic XPath in Selenium

Using multiple attribute


XPath in Selenium1


And so on.


Using contains method

And so on.

Dynamic Xpath in Selenium

Using starts-with method

Dynamic XPath in Selenium


Using Following node

 Dynamic Xpath in Selenium

Using preceding node

Dynamic Xpath in Selenium

Absolute XPath method





Relative and Absolute XPath method


Hope you are comfortable with xpath now. Please start writing xpath from your side and let me know if you are facing any issue.


For More updates Learn Automation page

For any query join Selenium group- Selenium Group



  1. Mandeep
  2. savita
  3. vinod singh
  4. vyshak
  5. Naira
  6. vinod singh
  7. Lee