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… 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();
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