Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Print

Selenium IDE Useful Xpath Patterns

When using Xpath in Selenium IDE or Selenium WebDriver to identify web elements, here are some useful patterns to locate dynamic values for element’s id attributes. 

  • text

//div[text()='selenium master']

  • starts-with

 

 

<input id="username-12345" /> where 12345 is a dynamic number you could use the following XPath:

//input[starts-with(@id, 'username-')]

  • contains

<span class="login module"> 

//span[contains(@class,'login')]

For the above xpath, using Css is faster and neater.  css=span.login.module