0% found this document useful (0 votes)
115 views4 pages

Contains Text //a (Contains (Text ,'text') ) Tags: // (@type 'Text') /following::input

This document summarizes XPath functions for selecting elements in an XML document. It describes functions such as contains, starts-with, text(), following, preceding, descendant, following-sibling, preceding-sibling, child, parent, self, and ancestor that can be used to locate elements based on attributes, text content, position, and relationships between elements. It also provides examples of how to use these functions with XPath expressions to select elements on a web page.

Uploaded by

Chinni Narayana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views4 pages

Contains Text //a (Contains (Text ,'text') ) Tags: // (@type 'Text') /following::input

This document summarizes XPath functions for selecting elements in an XML document. It describes functions such as contains, starts-with, text(), following, preceding, descendant, following-sibling, preceding-sibling, child, parent, self, and ancestor that can be used to locate elements based on attributes, text content, position, and relationships between elements. It also provides examples of how to use these functions with XPath expressions to select elements on a web page.

Uploaded by

Chinni Narayana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 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