Appium xpath accelerating apostrophes

I have the code below in my appium script:

public boolean isErrorDisplayedUnrecognisedLoginCredentials() { return appDriver.isElementExist(By.xpath("//UIAStaticText[@name='We don't recognize this user ID or password']")); } 

The test hangs because it treats the apostrophe in "not" as the last apostrophe to close the @name value. I tried to escape the apostrophe in "not" using \ ', \', & ap;

However, none of them work, and the tests continue to work. Does anyone know how to get around this?

0
source share
1 answer

AFAIK, you cannot escape quotes in xpath, but you can avoid quotes in Java. So try using escaped double quotes for the xpath literal string terminator, for example:

 By.xpath("//UIAStaticText[@name=\"We don't recognize this user ID or password\"]") 
+2
source

Source: https://habr.com/ru/post/1246639/


All Articles