Xpath ends-with

WebElement webElement = appiumDriver.findElement(By.xpath("//android.widget.TextView[ends-with(@text,‘the Future’)]"));

actua text is :“Welcome to the Future”

error:An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information)

Hi,

Have you tried with contains text ? e.g. //android.widget.TextView[contains(text(),‘the Future’)]

Have a try.

I tried it’s working!
Thanks

1 Like

Whenever you use “text”, make sure to use “text()” or “.”

In your case the below should work:

webElement = appiumDriver.findElement(By.xpath(“//android.widget.TextView[ends-with(text(),‘the Future’)]”));

webElement = appiumDriver.findElement(By.xpath(“//android.widget.TextView[ends-with(.,‘the Future’)]”));

I hope the above helps.

Thanks,
Uday

It’s nt working I tried.