What is Xpath?
• The Xpath is unique address for each and every element on the page.
• It is use for finding the position of the element.
• It is make for the every element
Selenium looks at highlighted element something which is to be unique (Eg: Name or id which is unique)
a. Attribute: (Name, size, value etc…)
b. First thing is need to be finding out unique id and name for that element …if not found then create own attribute like (XPath is this second level identification) Xpath is identification, what is path for that element …. But if tomorrow the application gets changes then the address that is "XPath" also change so write the XPath such way so it can be useful even if application also get change.
c. How to write the XPath :
d. XPath is the custom base on the certain element “attributes” and their respective “ values”
e. XPath Format:------ //html tag[@attribute name=’attribute value’]
f. Eg: //input [@type=’button’]
g. XPath can be specify with multiple attribute
h. If the Xpath is starting from the html gives the// before the XPath
You can find more good examples of XPath Syntax at W3C Schools
Using Firebug you can find out the XPath for the element.
There is one good add-on for to finding the XPath that is “XPath Checker” .it is interactive Editor for XPath expression.It’s give minimal XPath Expression to work
No comments:
Post a Comment