How to use contains in xpath

I use a xPath which uses contains and says it look like follow //*[contains(text(),“hi”)][1]] When i try to use ‘’ for the value hi its not finding the element instead when “” double quotes is given its finding the element.

The problem is when trying to use the value inside driver.findElementByXpath(locator) the double quotes is preceded by / like //*[contains(text(),"/hi/")][1]].

Kindly help on how to construct a xPath like foloowing**//*[contains(text(),“hi”)][1]**

read this article.

Can you try by giving this "//*[contains(text(),'successfully')]" or by"(..//*[contains(text(),'successfully')])[1]"

Try this, it worked for me
//*[contains(@label,"text you want to find")]
You can change @label for @name or @value


or use @text if it’s a text
//*[contains(@text,‘text you want to find’)]


Try this if not working complete contains text, @AndroidFindBy(xpath = “//*[ends-with(@text, ‘(Primary)’)]”)