Caused by: org.openqa.selenium.NoSuchElementException: Cannot locate an element using By.id: com.xxx.xxxapp:id/login_google

Hi everyone,

I’m starting to add Appium test to an aplicattion. The application is made in cordova and I’m having issues with my first test that will click a button to make login.
The connection with my phone is working but at the time that Appium have to execute my first test, it crashes with the following error ->

I’m getting the id from the browser inspector like this ->

What i’m doing wrong?

Thanks in advance!! :slight_smile:

element which you finding is not visible on screen, you can increase implicit wait time

1 Like

I agree with @pushpank. Screen is loading and Appium searches too fast for the element. Use an implicit wait to poll for the element until it is visible:

http://toolsqa.com/selenium-webdriver/implicit-explicit-n-fluent-wait/

1 Like

I have just tried to put a thread before the clic, but it seems to give me the same error :S in the screeen of the device the button is visible but the code doesn’t seems to find it.

Code with Thread or driver.manage()->
Captura

Same error (In error I can see that the time that the time t tried is alway the same, I’m making the thread or manage incorrectly?)->

I tried with the code you have given to me and the error still remains, in pushpank reply I post an explication.

i have the same problem with my native android app, sometimes appium doesn t find element even if the element is displayed.

You could try waiting until the element is enabled instead of displayed. I’ve had better luck using that as an explicit wait condition.

Have you tried increasing the time? I usually set some crazy long time (like 60 seconds) for POC since implicit wait polls and thus stops the timer once element is found. Later I go back and fine tune, but I always leave a buffer. The app I’m working on right now has 10 seconds of animation before the first screen is presented. I therefore implicitly wait for 20 seconds, and I think the elements are found in 11-12 seconds on average for that particular screen.

Since your mobile app is built in Cordova .
It generate a webview/HTML inside a native context.
As I can see the ID is given at ‘ons-button’ Tag .
And Cordova generate a child HTML component inside this tag .
You need to traverse to the child element insiDe ‘ons-button’ either through xpath or any other locator and then click .
Then it should work.

Try to add more wait with explicit wait like in blow code given 200sec and also try with change locator my it work

WebDriverWait wait = new WebDriverWait(driver,200); wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(“ABCl”)));