This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
23 / 28
Jul 2018

Have i mentioned appium 1.7.2 and java-client 5.0.4 i do not want to upgrade it is it ok to use these versions

Hey, can you provide the UI Automator view for carousel …
Thanks!!

Hi @Rathan_G,

Above line of code is incorrect.The constructor of TouchAction is only accept driver as parameter.

Incorrect:
TouchAction action =new TouchAction(getDriver().press(point(startx,starty))…)

Correct:
TouchAction action =new TouchAction(getDriver()).press(point(startx,starty)).moveTo.

or

TouchAction action =new TouchAction(getDriver());
action.press(point(startx,starty)).moveTo.

if u are using java client 5.0.4 you can use below code

public void swipeRightToLeft() {
Dimension size = webDriver.manage().window().getSize();
int startx = (int) (size.width *0.94);
int endx = (int) (size.width *0.24);
int starty = size.height / 2;
int finalendx = startx-endx;
int endy = 0;
(new TouchAction(webDriver)).press(startx,starty).moveTo(-finalendx,endy).release().perform();
}

Hi Tany,

im not getting error but horizontal swipe from right to left does not happen, press point works for 6.0v…kindly suggest im stuck.

appium 1.7.2
java-client : 6.0.0-BETA5

public void swipeRightToLeft() {
//getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Dimension size = getDriver().manage().window().getSize();
System.out.println(size);

int startx = (int) (size.width *0.94);
int endx = (int) (size.width *0.24);
int starty = size.height / 2;
int finalendx = startx-endx;
int endy = 0;
 
TouchAction actions = new TouchAction(getDriver());
actions.press(point(startx,starty)).waitAction(waitOptions(Duration.ofMillis(2000))).moveTo(point(finalendx, endy)).release().perform();

}

@Rathan_G if you are using appium 1.7.2 and java client 6.0.0 beta5, u have to use absolute coordinates for 1.7.2

public void swipeRightToLeft() {
//getDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Dimension size = getDriver().manage().window().getSize();
System.out.println(size);

int startx = (int) (size.width *0.94);
int endx = (int) (size.width *0.24);
int starty = size.height / 2;
int finalendx = startx-endx;
int endy = 0;

TouchAction actions = new TouchAction(getDriver());
actions.press(point(startx,starty)).waitAction(waitOptions(Duration.ofMillis(2000))).moveTo(point(-finalendx,endy)).release().perform();
}

if you use above code you may need to import below lines.

import java.time.Duration;
import static io.appium.java_client.touch.offset.PointOption.point;
import static io.appium.java_client.touch.WaitOptions.waitOptions;

Thanks for ur reply i updated from 5.0.4 to 6.0 because of press(point) not being compatible if it has to be actual co-ordinates will it affect different device size while running it…can u post an actual co-ordinates code…i really need to fix it fast …really appreciate it.

does it have anything to do with ui automator2? because im using uiautomator1

Hi tany

moveTo(point(-finalendx,endy)) here -finalendx is - (negative sign)required here

Sorry which part uiautomator2 or the -negative sign (-finalendx)

Thanks… dimension size (540, 888)

following co-ordinates i have put still it does not work

public void swipeRightToLeft() {
getDriver().manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
Dimension size = getDriver().manage().window().getSize();
System.out.println(size);

int startx = (int) (size.width *0.40);
int endx = (int) (size.width *0.20);
int starty = size.height / 2;
int finalendx = startx-endx;
int endy = 0;

TouchAction actions = new TouchAction(getDriver());
actions.press(point(270,444)).waitAction(waitOptions(Duration.ofMillis(2000))).moveTo(point(-finalendx,endy)).release().perform();

Can anyone please provide me any solution to swipe in java client 5.0.4;)

im getting the following exception

org.openqa.selenium.interactions.InvalidCoordinatesException: The coordinates provided to an interactions operation are invalid. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds

can anyone help me out please

1 month later

How to automate Swipe in android, I am still not able to get the final conclusion. On the screen it is banner and only way I can comeout is swipe 4 time (view all 4 banners) and then Login appeared. So please suggest how to automate.

Note: This is bannner so I can’t locate the element.