I am trying to locate a WebElement using XPath based on its text content.
The specific WebElement I want to find is:
https://i.sstatic.net/ji1jJ.png
Here is the HTML of the element:
https://i.sstatic.net/AyAqo.png
The WebElement I am trying to access contains an input element.
Currently, I am using the following code:
driver.findElement(By.xpath("//*[normalize-space(text()) = 'Own Hotel']"));
This XPath expression does not find the desired WebElement, even though it usually works for other elements.
I have also tried this XPath expression:
By.xpath("//*[contains(text(),'Own Hotel')]");
However, this method did not return any results either. I need an exact match for the text content.
I am searching for a way to locate a web element by its text regardless of any other elements inside it. If there is a match with the text, I want to retrieve the WebElement.
Thank you!