You are on page 1of 4

Contains

Text //a[contains(text(),'text')]
Tags //a[contains(@id,'id')]
//a[contains(@className,'className')]
//a[contains(.,'text')]

AND //*[@id='id' AND @class='class']

OR //*[@id='id' OR @class='class']

starts-with //*[starts-with(@id,'id')]
//input[starts-with(@name,'txt') OR @id='txtUsername']

text() //td[text()='text']
//li/a[text()='Performance']

Following //*[@type='text']/following::input

Peceding //div[@id='idester']/preceding::div

Descendant //div[@id='id']/descendant::a

following-sibling //a[@id='menu-item']/following-sibling::a

Preceding-sibling //form[@id='frmSelectEmployees']/preceding-sibling::div

Child //div[@id='idester']/child::li (equals) //div[@id='idester']/li

Parent //div[@id='branding']/parent::div

Self //*[@id='aboutDisplayLink']//self::a

Ancestor //span[text()='3 month(s)']/ancestor::div


. Means wild card any tagname

Both the conditions should be true,It fails to find element if any one condition is false

Any one condition should be true, it fails to find element if both conditions are false

 Start-with function finds the element whose attribute value changes on refresh or any operation on the webpage

http://www.guru99.com/xpath-selenium.html

Selects all input tags: after type='text' tag ---->(Irrespective of Node)

Selects all div tags before id='idester' ------->(Irrespective of Node)

It gives all 'a' tags under current node

Select the following siblings of the context node. Siblings are at the same level of the current node
It will find the element after the current node.

Select the Previous siblings of the context node. Siblings are at the same level of the current node
It will find the element after the current node.
(for following and precding will work only for nodes at same level)

Selects all children elements of the current node

Selects the parent of the current node

Selects the current node or 'self' means it indicates the node itself

The ancestor axis selects all ancestors element (grandparent, parent, etc.) of the current node
y operation on the webpage

(Not Much more Important)


id,name,xpath,className,linkText,partialLinkText,css

You might also like