List of usage examples for org.openqa.selenium.interactions.touch TouchActions move
public TouchActions move(int x, int y)
From source file:jp.co.nssol.h5.test.selenium.testcase.TouchTest.java
License:Apache License
public void touchActionsDoubleTap() throws InterruptedException, MalformedURLException { TouchActions touch = new TouchActions(getDriver()); touch.singleTap(getElementsByClassName("backgroundPiece").get(0)); touch.singleTap(getElementById("load")); touch.singleTap(getElementById("drawModeSwitch")); touch.build().perform();/*from www.j ava 2 s . c om*/ TouchActions touch2 = new TouchActions(getDriver()); Thread.sleep(1000); // O touch2.down(300, 450); touch2.move(280, 470); touch2.move(280, 550); touch2.move(300, 570); touch2.move(340, 570); touch2.move(360, 550); touch2.move(360, 470); touch2.move(340, 450); touch2.move(300, 450); touch2.up(300, 450); // K touch2.down(450, 450); touch2.move(450, 570); touch2.up(450, 570); touch2.down(450, 510); touch2.move(520, 450); touch2.up(520, 450); touch2.down(450, 510); touch2.move(520, 570); touch2.up(520, 570); touch2.build().perform(); takeScreenShot(); }
From source file:org.oneandone.qxwebdriver.ui.mobile.core.WidgetImpl.java
License:LGPL
public static void track(WebDriver driver, WebElement element, int x, int y, int step) { if (driver instanceof HasTouchScreen) { if (step == 0) { step = 1;// ww w . j av a2 s .c o m // TODO: no move if step == 0 } Point center = getCenter(element); int posX = center.getX(); int posY = center.getY(); int endX = posX + x; int endY = posY + y; TouchActions touchAction = new TouchActions(driver); touchAction.down(posX, posY); while ((x < 0 && posX > endX || x > 0 && posX < endX) || (y < 0 && posY > endY || y > 0 && posY < endY)) { if (x > 0 && posX < endX) { if (posX + step > endX) { posX += endX - (posX + step); } else { posX += step; } } else if (x < 0 && posX > endX) { if (posX - step < endX) { posX -= endX + (posX - step); } else { posX -= step; } } if (y > 0 && posY < endY) { if (posY + step > endY) { posY += endY - (posY + step); } else { posY += step; } } else if (y < 0 && posY > endY) { if (posY - step < endY) { posY -= endY + (posY - step); } else { posY -= step; } } touchAction.move(posX, posY); } touchAction.up(posX, posY).perform(); } else { Actions mouseAction = new Actions(driver); mouseAction.dragAndDropBy(element, x, y); } }