In my mobile app testing suite periodically appium is unable to click on an element after scrolling the page.
I am finding an element using uiautomator2 selectors and the scrollIntoView function then trying to click on the element.
EX:
@AndroidFindBy(uiAutomator = "new UiScrollable(new UiSelector().scrollable(true).instance(0))" +
".scrollIntoView(new UiSelector().resourceId(\"button_id").instance(0))")
private WebElement button;
button.click();
Assert.assertTrue(newPageDisplayed());
The code executes just fine and it believes that it has successfully clicked on the button navigating to the new page when in fact nothing happens and the assert fails.
I am using appium java-client 8.5.0 and appium 2.5.1 and the uiautomator driver 3.9.1
1 Enable on phone in Developer menu show touches and coordinates and double check that tap happens.
2 Possibly tap happens while scroll still in progress. This is expected. Try disable animation (on phone or with capability). Try play with waitForIdleTimeout
settings
3 Try first scroll and then tap on it.
4 Try check element clickable first. See java-client/src/e2eAndroidTest/java/io/appium/java_client/android/UIAutomator2Test.java at master · appium/java-client · GitHub →
final WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(30));
WebElement popUpElement = driver.findElement(AppiumBy.accessibilityId("Make a Popup!"));
wait.until(ExpectedConditions.elementToBeClickable(popUpElement)).click();
more to read about capabilities and settings → GitHub - appium/appium-uiautomator2-driver: Appium driver for Android UIAutomator2
I ended up disabling Window animations and that fixed it