use of io.appium.java_client.TouchAction in project activityinfo by bedatadriven.
the class Question method forward.
public Question forward() {
// JavascriptExecutor js = (JavascriptExecutor) driver;
// HashMap<String, Double> swipeObject = new HashMap<String, Double>();
// swipeObject.put("startX", 0.95);
// swipeObject.put("startY", 0.5);
// swipeObject.put("endX", 0.05);
// swipeObject.put("endY", 0.5);
// swipeObject.put("duration", 1.8);
// js.executeScript("mobile: swipe", swipeObject);
//
// HasTouchScreen touchScreen = (HasTouchScreen) driver;
// touchScreen.getTouch().flick(-500, 0);
//
// swipe across the screen horizontally
// driver.findElementById("form_forward_button").click();
// System.out.println(driver.getPageSource());
Dimension size = driver.manage().window().getSize();
int fromX = size.width - 10;
int toX = 10;
int y = size.height / 2;
TouchAction action = new TouchAction(driver);
action.press(fromX, y);
action.moveTo(toX, y);
action.release();
action.perform();
return this;
}
use of io.appium.java_client.TouchAction in project carina by qaprosoft.
the class AndroidUtils method pressBottomRightKey.
/**
* Pressing bottom right button on the keyboard by coordinates: "search",
* "ok", "next", etc. - various keys appear at this position. Tested at
* Nexus 6P Android 8.0.0 standard keyboard. Coefficients of coordinates for
* other devices and custom keyboards could be different.
*/
public static void pressBottomRightKey() {
WebDriver driver = DriverPool.getDriver();
Dimension size = driver.manage().window().getSize();
int height = size.getHeight();
int width = size.getWidth();
new TouchAction((AndroidDriver<?>) driver).tap(Double.valueOf(width * 0.915).intValue(), Double.valueOf(height * 0.945).intValue()).perform();
}
use of io.appium.java_client.TouchAction in project carina by qaprosoft.
the class MobileUtils method swipe.
/**
* Swipe by coordinates using TouchAction (platform independent)
*
* @param startx int
* @param starty int
* @param endx int
* @param endy int
* @param duration int Millis
*/
public static void swipe(int startx, int starty, int endx, int endy, int duration) {
LOGGER.debug("Starting swipe...");
WebDriver drv = DriverPool.getDriver();
LOGGER.debug("Getting driver dimension size...");
Dimension scrSize = drv.manage().window().getSize();
LOGGER.debug("Finished driver dimension size...");
// explicitly limit range of coordinates
if (endx > scrSize.width) {
LOGGER.warn("endx coordinate is bigger then device width! It will be limited!");
endx = scrSize.width - 1;
} else {
endx = Math.max(1, endx);
}
if (endy > scrSize.height) {
LOGGER.warn("endy coordinate is bigger then device height! It will be limited!");
endy = scrSize.height;
} else {
endy = Math.max(1, endy);
}
LOGGER.info("startx: " + startx + "; starty: " + starty + "; endx: " + endx + "; endy: " + endy + "; duration: " + duration);
new TouchAction((MobileDriver<?>) drv).press(startx, starty).waitAction(Duration.ofMillis(duration)).moveTo(endx, endy).release().perform();
LOGGER.debug("Finished swipe...");
}
use of io.appium.java_client.TouchAction in project opentest by mcdcorp.
the class TapByCoordinates method run.
@Override
public void run() {
super.run();
Integer x = this.readIntArgument("x");
Integer y = this.readIntArgument("y");
TouchAction touchAction = new TouchAction(driver);
touchAction.tap(x, y).perform();
}
use of io.appium.java_client.TouchAction in project opentest by mcdcorp.
the class AppiumTestAction method getActionsInstance.
/**
* Creates a new TouchAction object (if it doesn't exist yet) and returns
* it. The TouchAction class can be used for emulating complex user gestures
* on touch-enabled devices.
*/
public static TouchAction getActionsInstance() {
if (AppiumTestAction.actions == null) {
Logger.debug("Creating a new TouchAction instance...");
AppiumTestAction.actions = new TouchAction(AppiumHelper.getDriver());
}
return AppiumTestAction.actions;
}
Aggregations