jeudi 19 février 2015

PageFactory.initElements() doesn't always guarantee the objects are initialized- assertion fails - running on real iPhones

I am tying to run appium tests on 2 real iPhones using the pages design patterns. The objects on each page are initialized using annotations like this:



@iOSFindBy(name = "Custom menu.")

protected MobileElement customMenuBtn;


and when a new page is created I use : PageFactory.initElements to initialize it.


When a new page is created an assertion is made to verify I am on the right page:



public void assertInPage() {
try {
waitForElement(customMenuBtn);
}
catch (Exception e) {
e.printStackTrace();
}
}


Waiting for this element of a page that exist and isn't null sometimes fail and I get NoSuchElementException This error is inconsistent and it can happen at the first time I create this page or after i return to it. I can't try it on simulators so i am running on real devices. Is it possible the initelements doesn't actually init all elements even though they are all visible on screen. I am using appium 1.3.4 and 1.3.5 and it happens in both.


Have been stuck on this for a few days now , any ideas ...?


Aucun commentaire:

Enregistrer un commentaire