0% found this document useful (0 votes)
0 views3 pages

Xpath 9.00AM

Xp

Uploaded by

Athul Shaji
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)
0 views3 pages

Xpath 9.00AM

Xp

Uploaded by

Athul Shaji
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/ 3

Xpath:

======
XML Path

1.To validate the locator


2.If id,name,class not present

Types:
======
1.Absolute Xpath(/) ----> it is taken from root to desireded tagName(down strom)
2.Relative Xpath(//) ----> it directly taken from desireded tagName

functionality:
==============
1.attribute xpath:
==================
//tagName[@attribute='attributeValue']

2.index xpath:
==============
(//tagName[@attribute='attributeValue'])[index]

3.Text xpath:
=============
//tagName[text()='textValue']

4.Contains Text Xpath:


======================
//tagName[contains(text(),'partialtext')]

5.Contains attribute Xpath:


===========================
//tagName[contains(@attribute,'partial attribute value')]

6.Starts-with(attribute):
========================
//tagName[starts-with(@attribute,'starting attribute value')]

Example://input[starts-with(@id,'e')]

7.Starts-with(text):
====================
//tagName[starts-with(text(),'staring text')]

8.And
=====
//input[@attributeName='att value' and @attributeName='att value']

Example://input[@id='email' and @name='email']

9.Or:
=====
//input[@attributeName='att value' or @attributeName='att value']

Example://input[@id='email' or @name='email']
10.Unknown tagName:
===================
//*[@attributeName='attributeValue']

Example://*[@id='email']

Xpath with axes:


================

11.Parent:
==========
//<knownXapth>//parent::elementName

Example://input[@id='email']//parent::div

12.Following Sibling:
=====================
//<xpathofknownElement>//following-sibling::<elementName>

Example://input[@name='login_source']//following-sibling::input

13.Preceding Sibling:
=====================
//<xpathofknownElement>//preceding-sibling::<elementName>

Example://input[@name='next']//preceding-sibling::input

14.Child:
=========
//<knownXapth>//child::elementName

Example://div[@id='passContainer']//child::input

15.ancestor:
============
//<xpathofknownElement>//ancestor::<elementName>

Example://input[@id='email']//ancestor::div

You might also like