The React-Native application that I am testing has a modal view with payment methods
When a credit card element is getting moved horizontally (right-to-left), a new button “REMOVE” opens that allows the corresponding card to be removed from the user account
Using the XPath, I can get a list of mobile elements for TextView “MasterCard ****4444, 12/2020” and then randomly pick one. However sliding that element to open the button proved to be challenging. I have tried
int screenWidth = (int) driver.manage().window().getSize().width;
MobileElement chosenCreditCard = paymentMethodsList.get(chosenItem);
TouchAction touchAction = new TouchAction(driver);
touchAction.press(paymentMethodsList.get(chosenItem)).moveTo(-0.5*screenWidth, 0).release().perform();
and
int screenWidth = (int) driver.manage().window().getSize().width;
MobileElement chosenCreditCard = paymentMethodsList.get(chosenItem);
int chosenCreditCardY = chosenCreditCard.getLocation().getY();
TouchAction touchAction = new TouchAction(driver);
touchAction.press(0.8*screenWidth, chosenCreditCardY).moveTo(-0.5*screenWidth, 0).release().perform();
But neither way works. When I observe the action on my phone, the element is getting shifted just a bit, may be by 50 units, and moves back, i.e. the “REMOVE” button does not appear. Appium logs show both press and moveTo actions
responded with 200
. I tried adding waitAction before the release() but it seems to do nothing.
What am I possibly missing here?
My setup:
- com.microsoft.appcenter.appium.EnhancedAndroidDriver
- Appium server 1.7.2 / 1.8.0
- Java 1.8.0.152
- io.appium:java-client:5.0.4
- Sony XPERIA M4 (Android 5.0.1)