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"> 


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