Search in sources :

Example 1 with TouchAction

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;
}
Also used : Dimension(org.openqa.selenium.Dimension) TouchAction(io.appium.java_client.TouchAction)

Example 2 with TouchAction

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();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Dimension(org.openqa.selenium.Dimension) TouchAction(io.appium.java_client.TouchAction)

Example 3 with TouchAction

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...");
}
Also used : WebDriver(org.openqa.selenium.WebDriver) MobileDriver(io.appium.java_client.MobileDriver) Dimension(org.openqa.selenium.Dimension) TouchAction(io.appium.java_client.TouchAction)

Example 4 with TouchAction

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();
}
Also used : TouchAction(io.appium.java_client.TouchAction)

Example 5 with TouchAction

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;
}
Also used : TouchAction(io.appium.java_client.TouchAction)

Aggregations

TouchAction (io.appium.java_client.TouchAction)26 MultiTouchAction (io.appium.java_client.MultiTouchAction)12 Test (org.junit.Test)12 MobileElement (io.appium.java_client.MobileElement)6 Point (org.openqa.selenium.Point)6 MessageEvent (org.cerberus.engine.entity.MessageEvent)4 Dimension (org.openqa.selenium.Dimension)4 WebElement (org.openqa.selenium.WebElement)4 WebDriver (org.openqa.selenium.WebDriver)3 By (org.openqa.selenium.By)2 NoSuchElementException (org.openqa.selenium.NoSuchElementException)2 WebDriverException (org.openqa.selenium.WebDriverException)2 MobileDriver (io.appium.java_client.MobileDriver)1 IOSTouchAction (io.appium.java_client.ios.IOSTouchAction)1 ElementOption (io.appium.java_client.touch.offset.ElementOption)1 PointOption.point (io.appium.java_client.touch.offset.PointOption.point)1 Parameter (org.cerberus.crud.entity.Parameter)1 SwipeAction (org.cerberus.engine.entity.SwipeAction)1 Direction (org.cerberus.engine.entity.SwipeAction.Direction)1 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)1