I am currently designing Appium Android framework based on page object and page Factory.
I have a below line of code which uses “findElementByAndroidUIAutomator”.
driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(text("Brazil"));");
I wanted to convert it to page Factory format like below example.
@AndroidFindBy(id="android:id/text1") public WebElement clickOnDropDown;
As I checked I didn’t not find any definite answers regarding this. Just wanted to check as findElementByAndroidUIAutomator is android function not appium. So how can we convert this line to page factory format ?
Advertisement
Answer
You can do it this way:
@AndroidFindBy(uiAutomator = "new UiScrollable(new UiSelector()).scrollIntoView(text("Brazil"));") public WebElement brazilLabel;
The only downside is that you can’t pass argument (“e.g Brazil”) to annotation