I need to swipe my app(Both from left to right and right to left), wherelse I am using Java in appium for android native app automation.
I have tries this link, Swipe method not working in android automation testing
But i can't, is any other link please share or anyone help me out.
Here is how we do it-
Swipe left-
appiumDriver.context("NATIVE_APP");
Dimension size = appiumDriver.manage().window().getSize();
int startx = (int) (size.width * 0.8);
int endx = (int) (size.width * 0.20);
int starty = size.height / 2;
appiumDriver.swipe(startx, starty, endx, starty, 1000);
Swipe right-
appiumDriver.context("NATIVE_APP");
Dimension size = appiumDriver.manage().window().getSize();
int endx = (int) (size.width * 0.8);
int startx = (int) (size.width * 0.20);
int starty = size.height / 2;
appiumDriver.swipe(startx, starty, endx, starty, 1000);
Here appiumDriver is an instance of io.appium.java_client.AppiumDriver
swipe() method is deprecated.
so we can use below methods.
Swipe left will be perform as:
new TouchAction(driver).longPress(250, 1200).moveTo(900, 1200).release().perform();
Swipe right will be perform as:
new TouchAction(driver).longPress(1000, 450).moveTo(500, 450).release().perform();
Here, driver is your driver like AndroidDriver
, RemoteWebDriver
, AppiumDriver
.
And 250, 1200 and other is Your app view Co-ordinate that you can see in the UIAutomaterView batch file located under the android-sdk platform-tools.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With