appium#52 Add @FindBy annotations for appium's extra locator strategies by TikhomirovSergey · Pull Request #68 · appium/java-client
WebElement can be instantiated by these ways:
@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 //an instance of PageObject.class );
or
PageFactory.initElements(new AppiumFieldDecorator(driver, 15, //default implicit waiting timeout for all strategies TimeUnit.SECONDS), pageObject //an instance of PageObject.class );
I made some tests. If there is not enough please add your own.