-1

I need to retrieve the xpath of element on a page but all I know about the element is that it will contain a certain string let's say "required text" and that it will sit in a div. I would like to search the page for this string and return the xpath to this div.

I have tried something like:

${findXPath} =   Get Element Attribute   //*[contains(text(),'required text')]   xpath

but this returns nothing.

  • I guess this is your xpath `//*[contains(text(),'required text')]` already where `required text` would be variable value for each different element. – Sariq Shaikh Nov 18 '20 at 07:27

1 Answers1

0

XPath isn't an WebElement's attribute. is a element Locating Strategy.

So Selenium won't be able to return the xpath

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352