-
-
Notifications
You must be signed in to change notification settings - Fork 762
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
Add @FindBy annotations for appium's extra locator strategies #52
Comments
Hi! I made some draft which you can check out in my fork here: https://github.com/TikhomirovSergey/java-client/tree/master/src/main/java/io/appium/java_client/pagefactory Decorator: https://github.com/TikhomirovSergey/java-client/blob/master/src/main/java/io/appium/java_client/pagefactory/MobileFieldDecorator.java is the target. The estimated way of usage is |
Idea is changed: PageFactory.initElements(new MobileElementLocatorFactory(driver), page); If you like this idea I can commit all that was done here - https://github.com/appium/java-client. But firstly I should test this. |
I think that for native apps we need to have separate |
To @prattpratt |
@TikhomirovSergey , my idea is that we definitely need both android and ios search strategies attached to every uielement. So you can specify completely different search strategies for Android and for IOS app (e.g. @AndroidFindBy(id = "android:id/alert_dialog_title")
@IOSFindBy(xpath = "//UIAAlert/UIAScrollView/UIAStaticText[1]")
MobileElement alertTitle; It's a bit complicated but I think it is realizable for sure. And it will be more reusable approach because we will have a single test scripts set for both Android & IOS app that share the same UI. |
Yaeh! It is the great idea! |
I will implement this soon. |
I made annotations @AndroidFindBy and @iosFindBy. Also MobileAnnotations was remade. It not final result. MobileElementLocator.java has to be remade. All this stuff should be tested. |
Awesome! I'm on vacation for the next week, but will be happy to write some tests and review the code. About having the AndroidFindBy and iosFindBy, I was thinking of eventually creating two separate Driver classes. iosDriver and AndroidDriver, which both inherit from MobileDriver. Then there will no longer be confusion about which methods are unsupported on each platform. If the split is done like this, then there could be some default behavior in which search strategies are available on elements. |
It is almost finished but is not tested. The next step is to prepare tests and to fix bugs that can be found out. |
Hi! @FindBy(someStrategy) //for browser or Html UI
@AndroidFindBy(someStrategy) //for Android UI of the same application. Strategies are:
//uiAutomator, accessibility, id, name, className, tagName, xpath
//@AndroidFindBys({@AndroidFindBy(someStrategy1), @AndroidFindBy(someStrategy2)}) is for chained search
@iOSFindBy(someStrategy) //for iOS UI of the same application. Strategies are:
//uiAutomator, accessibility, id, name, className, tagName, xpath
//iOSFindBys({@iOSFindBy(someStrategy1), @iOSFindBy(someStrategy2)}) is for chained search
WebElement someElement; or @FindBy(someStrategy)
@AndroidFindBy(someStrategy)
@iOSFindBy(someStrategy)
RemoteWebElement someElement; or @AndroidFindBy(someStrategy)
@iOSFindBy(someStrategy)
MobileElement someElement; Now old browser page objects can be reusable with this decorator: PageFactory.initElements(new AppiumFieldDecorator(driver), pageObject); or PageFactory.initElements(new AppiumFieldDecorator(driver,
15, //default implicit waiting timeout for all strategies
TimeUnit.SECONDS),
pageObject); All implemented functionality you can see here: Tests are here: I have run test of Android and browser compatibility (Passed). Test for iOS will be run soon. I will make a pull request as soon as possible (maybe tomorrow). If there is all righ it will be the killer feature. |
fot Page tests and page factory if @findby is used to locate some element on hybrid app (web view - FB login page) then should testers need to explicitly change the context of the AppoumDriver? |
@iOSFindBy(name = "XXXX") not working in the java-client version > 4.1.0. Getting below error, 'name'is not part of the annotation io.appium.java_client.pagefactory.iOSFindBy |
@Henkoglobin |
what strategy to use if have same locator id for iOS and Android ? |
As mentioned in #22
The text was updated successfully, but these errors were encountered: