4.2. Locator Table
This table help to get locator from Web
Category
Recipe
XPath
CSS
General
Whole web page
/html
html
Whole web page body
/html/body
body
Tag
Element by relative reference
//E
E
Second element anywhere on page
(//E)[2]
NA
Element with attribute A
//E[@A]
E[A]
Element with attribute A containing text 't' exactly
//E[@A='t']
E[A='t']
Element with attribute A containing text 't'
//E[contains(@A,'t')]
NA
Id & Name
Element <E> with id I
//E[@id='I']
E#I
Element with id I
//*[@id='I']
#I
Element <E> with name N
//E[@name='N']
E[name=N]
Element with name N
//*[@name='N']
[name=N]
Class
Element <E> with class C
//E[@class='C']
E.C
Text
Element <E> containing text t exactly
//E[.='t']
NA
Element <E> containing text t
//E[contains(text(),'t')]
NA
Last updated
Was this helpful?