Search for element and store its xpath location

hi, i want to search for element (eg. text ‘garden’) on a website, then store its location (xpath) which i require to use.

any help is welcome.

Does this info help?

Thanks admin, I tried those methods but maybe I am not too advanced to not use them properly in this case.

Here I am trying to get reverse xpath location for a text string (eg. text ‘garden’) in a website.

  1. text ‘garden’ is first searched in a page if not goes to next page (I can get this step)

  2. If ‘garden’ found, I require to extract it’s xpath location

Thanks in advance

Why this? Can you explain this requirement further? Then hopefully I have an idea on how to solve it.

my target is ‘flower’ element corresponding to ‘garden’ element. As xpath of ‘flower’ is dependent on xpath location of ‘garden’.

I have list of ‘garden’ to start with (eg. garden1, garden2,…) Xpath Location of garden differs on every page, but relative xpath is constant with ‘flower’ element.

Starting point is list of ‘garden’ elements and target is list of 'flower’elements.


If you already have a way to get the Node (javascript or HTML node) of the Garden then you could just use getPath(node) in an executeScript command.

sorry its advanced for me, but is it possible to search a text in a web page and use executescript to return xpath location of that searched text.