0% found this document useful (0 votes)
11 views1 page

Xpath Contains

The document explains how to use XPath functions such as 'contains', 'sibling', and 'ancestor' to extract and locate web elements based on specific criteria. Examples are provided for each function to illustrate their usage in selecting elements related to text values, sibling relationships, and parent elements. This information is useful for web scraping and automated testing scenarios.

Uploaded by

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

Xpath Contains

The document explains how to use XPath functions such as 'contains', 'sibling', and 'ancestor' to extract and locate web elements based on specific criteria. Examples are provided for each function to illustrate their usage in selecting elements related to text values, sibling relationships, and parent elements. This information is useful for web scraping and automated testing scenarios.

Uploaded by

qavasutesting
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Contains:

By using 'contains' function in XPath, we can extract all the elements which
matches a particular text value.

"//h4/a[contains(text(),'SAP M')]"

Sibling:

Using sibling keyword, we can fetch a web element on the which is related to some
other element.

"//div[@class='canvas- graph']//a[@href='/accounting.html'][i[@class='icon-
usd']]/following-sibling::h4"

Ancestor:

To find an element on the basis of the parent element we can use ancestor
attribute of XPath.

"//div[.//a[text()='SELENIUM']]/ancestor::div[@class='rt-grid-2
rt-omega']/following-sibling::div"

You might also like