JaysonP JaysonP - 1 year ago 125
Java Question

Appium: Cannot find an element that is visible

I am currently trying to automate a login flow. The coding for the happy path works properly. I am now coding for invalid credentials.

My code looks similar to this:

//At this point the button is pressed
Thread.sleep(10000); //Screen with the following item is definitely visible
MobileElement actual = (MobileElement)(new WebDriverWait(driver, 30).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//android.view.View[@content-desc='Invalid user ID or password. Try again']"))));
//Note when I print out the xml and use xpathfinder I get 1 response

I am getting this response:

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

Answer Source

So the issue is that the getAttribute("content-desc") is not what appium is looking for. Instead using getAttribute("name") will return the desired value(aka content-desc).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download