Home Core Java Overview Maven Tutorials

Wednesday, 8 March 2017

How to create xPath & Css path Manually

For Video Tutorial : Move on Youtube Channel

Note : Select the playlist as per your need & move with number sequence

How to Create Dynamic Xpath & CSS Path :

Xpath with single attribute :
xpath Sysntax :
//tagname[@attributename = 'value of attribute']

For example :
//input[@id = 'uname']

xpath with multiple attribute :
xpath Sysntax :
//tagname[@attributename = 'value of attribute'][@attributename = 'value of attribute']
For example :
//input[@id = 'uname'][@class = 'input']

xpath with and :
//input[@id = 'uname' and @class = 'input']

xpath with or:
//input[@id = 'uname' OR @class = 'input']

xpath with contains :
//tagname[contains(@attributename = 'value of attribute')]

//input[contains(@id = 'pass')]

xpath with starts with :
//*[starts-with(@attributename , 'attribute value')]

//*[starts-with(@id, 'uname')]

xpath with following :
//*[text() = 'Discussion']//following::a[contains(@href, 'edit.php')]

How to Create Dynamic CSS Path manually:

Sr No.AttributeSymbol
1.For Class NameUse . Symbol
2.For idUse # Symbol
3.For attributetagname[attribute = 'value']
4.For Multiple Attributetagname[attribute1 = 'value'][attribute2 = 'value']
5.Starts withUse ^ Symbol
6.Ends WithUse $ symbol
7.Containsuse * Symbol


Difference between Xpath & Selenium

1).Xpath engines are different in each browser, hence make them inconsistent Css path works in each browser whereas xpath is limited with browsers for Example IE browser.
2).CSS was initially released in 1996 & xpath was initially released in the 1999.
3).CSS is easy as compaired to Xpath.

No comments:

Post a Comment