-
-
Notifications
You must be signed in to change notification settings - Fork 757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOSFindBy & AndroidFindBy annotations are ignored #211
Comments
Hey, could you post your capabilities as well? I've been using page factory extensively and haven't encountered this issue. |
System.out.println(driver.getCapabilities().toString()); outputs for an Android test: Capabilities [{networkConnectionEnabled=true, desired={}, platformVersion=4.4.4, warnings={}, webStorageEnabled=false, locationContextEnabled=false, browserName=Android, takesScreenshot=true, javascriptEnabled=true, databaseEnabled=false, deviceName=192.168.56.101:5555, platform=LINUX}] and for an iOS test: Capabilities [{networkConnectionEnabled=false, desired={}, warnings={}, webStorageEnabled=false, locationContextEnabled=false, browserName=iOS, takesScreenshot=true, javascriptEnabled=true, databaseEnabled=false, platform=MAC}] I also dug a bit deeper into the debugger for the particular field I've included above as it's being decorated by the PageFactory and it shows no annotations (I'm not sure if it should): |
@justintilson Hi! |
Are you tryng to use iOSFindBy for Android
? Please improve your page object as follows @iOSFindBy(accessibility = "home_landing_my_favorites_count_label")
@AndroidFindBy(your locator for android)
private WebElement myFavoritesCountLabel; What the result? |
@TikhomirovSergey, I'm testing native apps on Android and iOS. I have separate tests and page objects for Android and iOS and use the appropriate @findby in each. |
Ok. If I clearly understand you Appuim features allow to implement one page object for Android/iOS/browser testing. Please look at this @iOSFindBy(locator_for_ios) //this locater is used when here is iOS native content
@AndroidFindBy(locator_for_android)//this locator is used when here
//is Android native content
@FindBy(locator_for_HTML)//this locator is used when here mobile
//or desktop browser or webview
private WebElement myFavoritesCountLabel; Ok. Is this used with Android public class HomePhonePage extends BaseHomePage {
public HomePhonePage(AppiumDriver driver) {
super(driver);
PageFactory.initElements(new AppiumFieldDecorator(driver,
IMPLICIT_WAIT,
TimeUnit.SECONDS),
this
);
}
@iOSFindBy(accessibility = "home_landing_my_favorites_count_label")
private WebElement myFavoritesCountLabel;
public String getMyFavoritesCountLabel() {
return myFavoritesCountLabel.getText();
}
} ?
|
...I am just trying to understand your problem and usecase :) |
@TikhomirovSergey - I understand that I can use a single page object to test both platforms but I've found in this particular instance it didn't work out well because the implementations are somewhat different and evolving at different rates. Here is the Android page object (same as iOS in this instance but in a different package): public class HomePhonePage extends BaseHomePage {
public HomePhonePage(AppiumDriver driver) {
super(driver);
PageFactory.initElements(new AppiumFieldDecorator(driver,
IMPLICIT_WAIT,
TimeUnit.SECONDS),
this
);
}
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"com.wholefoods.wholefoodsmarket:id/tvFavOrangeBubble\")")
private MobileElement myFavoritesCountLabel;
public String getMyFavoritesCountLabel() {
return myFavoritesCountLabel.getText();
}
} |
ok. Now it is clear. Is your app hybrid? Appium-specific annotations were designed for native contents. What does return .getContext() method before your test is failed? |
System.out.println(driver.getContext()); prints: NATIVE_APP |
Ok. Is it possible that your project is still depending on java_client 2.2.0 or lower? Please look at your dependencies hierarchy. |
I thought that might have had something to do with it so I upgraded yesterday. Here is my build.gradle file:
and the gradle cache: |
And when you are running
it is printing
Am I right? It interesting where is platformName = "Android". |
Ok. I have two things to say. The second. If I am right then there is the strange difference between given and printed capabilities. The absence of "platformName" parameter causes your problem. |
I changed the 'platformName' desired capability to 'platform' with no difference and then tried both platform and platformName with the same result. Here is the DesiredCapabilities instance that is passed to the AndroidDriver's constructor: and this is how they read after the driver has been instantiated: I'm not sure where LINUX is coming from but it's not something I seem to be able to control. |
I tried switching to node server (instead of Appium.app) and got the same results. It's still trying to use the property name of the page object to find elements instead of using the values provided in the annotations. |
@justintilson The PR is proposed and now it is waiting for the merging. |
@TikhomirovSergey - thanks for the update and your speedy fix. How long is typical for a merge? Our tiny team of two is somewhat blocked by this issue. |
It is depending on @Jonahss |
@justintilson merged! |
@Jonahss - our current gradle build script pulls from the Maven repo. I could probably tweak it to download the source and compile it if you weren't planning to do a release for a while. If it's relatively effortless to do a release, that would accelerate things on my side. |
@justintilson Yeah I can do a release :) I'll start running the test suite now. |
@justintilson Ok, released version 3.1.0 |
It works! I tested on both Android and iOS. @TikhomirovSergey, @Jonahss Thanks so much for moving this issue through so quickly! |
Yay! On Mon, Jul 6, 2015 at 3:57 PM, Justin Tilson notifications@github.com
|
I'm happy :) |
one question. Do I need to change the context of the driver before I try to locate webview elements (hybrid app - like FB login) by using Page Objects/Factory as mentioned above? FindBy(locator_for_HTML)//this locator is used when here mobile |
I've been trying for a couple of days to get iOSFindBy & AndroidFindBy annotations working with page objects and the PageFactory. I've tried versions 2.2.0 and 3.0.0 of the java-client and tests for Android and iOS, all with the same result - which is the same as not including any annotations.
Here is a truncated version of one of my page objects
My test code:
When I debug into PageFactory.initElements, I see [unknown locator] for each property that is a WebElement. Then the PageFactory defaults to looking for each page object's property name as the id or name of the WebElement and fails to find anything.
I suspect "I'm doing it wrong" but I can't figure out where. It is behaving as if the annotations are not even there.
The text was updated successfully, but these errors were encountered: