How to get relative path in XPath?

danish picture danish · Nov 11, 2014 · Viewed 12.6k times · Source

I am facing an issue with FirePath
I am getting

html/body/center/center[3]/form/table/tbody/tr[1]/td[2]/input

from the XPath of the FirePath. This is an absolute path.
But I need a relative path. How to get it?

Answer

Surya picture Surya · Nov 11, 2014

Better way is to write your own custom relative xpath.

There is an alternate way to get the relative xpath with help of the FirePath tool also. To get relative XPATH: Click on the drop down menu on the Firepath button and Unselect ‘Generate absolute XPath’.As shown below:

Then you should be getting relative XPATH (remove the "." from generated XPATH) as shown below: enter image description here