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 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:
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()->
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?)->
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.