Example usage for org.openqa.selenium.interactions.touch TouchActions TouchActions

List of usage examples for org.openqa.selenium.interactions.touch TouchActions TouchActions

Introduction

In this page you can find the example usage for org.openqa.selenium.interactions.touch TouchActions TouchActions.

Prototype

public TouchActions(WebDriver driver) 

Source Link

Usage

From source file:com.ecofactor.qa.automation.platform.action.impl.AndroidUIAction.java

License:Open Source License

/**
 * Swipe.// w ww  .  j a  v  a 2  s.  c o  m
 * @param element the element
 * @param xCoordinate the x coordinate
 * @param yCoordinate the y coordinate
 * @param distance the distance
 * @param speed the speed
 * @param direction the direction
 * @see com.ecofactor.qa.automation.mobile.action.impl.AbstractMobileUIAction#swipe(org.openqa.selenium.WebElement,
 *      double, double, double, double,
 *      com.ecofactor.qa.automation.mobile.action.impl.AbstractUIAction.Direction)
 */
@Override
protected void swipe(final WebElement element, final double xCoordinate, final double yCoordinate,
        final double distance, final double speed, final Direction direction) {

    final int xOffset = (int) (getEndX(xCoordinate, distance, direction) - xCoordinate);
    final int yOffset = (int) (getEndY(yCoordinate, distance, direction) - yCoordinate);
    final int speedValue = (int) speed;
    final TouchActions flick = new TouchActions(driverOps.getDeviceDriver()).flick(element, xOffset, yOffset,
            speedValue);
    flick.perform();
    setLogString("Save mobile swipe screenshot for test: " + getTestName(), true);
}

From source file:com.ecofactor.qa.automation.platform.action.impl.AndroidUIAction.java

License:Open Source License

/**
 * swipe the window at window size./*from  w  w w  . j a v a  2 s  .co  m*/
 * @param element
 * @param xCoordinate
 * @param yCoordinate
 * @param speed
 * @param direction
 * @see com.ecofactor.qa.automation.platform.action.impl.AbstractMobileUIAction#swipe(org.openqa.selenium.WebElement,
 *      double, double, double,
 *      com.ecofactor.qa.automation.platform.action.impl.AbstractUIAction.Direction)
 */
@Override
protected void swipe(final WebElement element, final double xCoordinate, final double yCoordinate,
        final double speed, final Direction direction) {

    final int xOffset = (int) (getEndX(xCoordinate, getWindowWidth(element), direction));

    final int yOffset = (int) (getEndY(yCoordinate, getWindowHeight(element), direction));
    final int speedValue = (int) speed;

    final TouchActions flick = new TouchActions(driverOps.getDeviceDriver()).flick(element, xOffset, yOffset,
            speedValue);
    flick.perform();
    setLogString("Save mobile swipe screenshot for test: " + getTestName(), true);

}

From source file:com.nike.tests.MobileWebTest.java

License:Apache License

@Test
public void shouldSearchWithEbay() {
    // And now use this to visit ebay
    driver.get("http://m.ebay.de");

    System.out.println("starting flick");
    //WebElement pages = driver.findElement(By.id("vp_pages"));
    TouchActions flick = new TouchActions(driver).flick(100, 860);
    flick.perform();/*from   w  w  w . j a v a 2s.co  m*/
    TouchActions swipe = new TouchActions(driver).scroll(-200, 860);
    swipe.perform();

    TouchAction ta = (new TouchActionBuilder()).pointerDown(200, 860).pointerMove(100, 10).pointerUp().build();
    ta.perform(driver);
    System.out.println("done");
    // Find the text input element by its id
    WebElement element = driver.findElement(By.id("kw"));

    // Enter something to search for
    element.sendKeys("Nexus 5");

    // Now submit the form. WebDriver will find the form for us from the element
    element.submit();

    // Check the title of the page
    System.out.println("Page title is: " + driver.getTitle());
    driver.quit();
}

From source file:com.sugarcrm.candybean.examples.mobile.AppiumAndroidTest.java

License:Open Source License

@Test
public void testSlider() throws Exception {
    //get the slider
    WebElement slider = driver.findElement(By.xpath("//seek[1]"));
    //        assertEquals(slider.getAttribute("value"), "50%");
    TouchActions drag = new TouchActions(driver).flick(slider, new Integer(-1), 0, 0);
    //        drag.perform();
    //        assertEquals(slider.getAttribute("value"), "0%");
}

From source file:com.sugarcrm.candybean.examples.mobile.AppiumIosTest.java

License:Open Source License

@Test
public void testSlider() throws Exception {
    //get the slider
    WebElement slider = driver.findElement(By.xpath("//slider[1]"));
    assertEquals(slider.getAttribute("value"), "50%");
    TouchActions drag = new TouchActions(driver).flick(slider, new Integer(-1), 0, 0);
    drag.perform();/*  www. j a va 2s.com*/
    assertEquals(slider.getAttribute("value"), "0%");
}

From source file:com.vilt.minium.actions.touch.TouchInteraction.java

License:Apache License

@Override
protected TouchActions newActions(WebElement elem) {
    return new TouchActions(((WrapsDriver) elem).getWrappedDriver());
}

From source file:io.appium.java_client.android.AndroidTouchActionsTest.java

License:Apache License

@Test
public void singleTapTest() throws Exception {
    driver.startActivity("io.appium.android.apis", ".view.Buttons1");
    Thread.sleep(5000);/*from  ww w  .  jav a  2s.  c  om*/
    new TouchActions(driver).singleTap(driver.findElementById("io.appium.android.apis:id/button_toggle"))
            .perform();
    Thread.sleep(5000);
    assertEquals("ON", driver.findElementById("io.appium.android.apis:id/button_toggle").getText());
}

From source file:io.appium.java_client.android.AndroidTouchActionsTest.java

License:Apache License

@Test
public void horizontalFlickTest() throws Exception {
    driver.startActivity("io.appium.android.apis", ".view.Gallery1");

    AndroidElement gallery = driver.findElementById("io.appium.android.apis:id/gallery");
    List<MobileElement> images = gallery.findElementsByClassName("android.widget.ImageView");
    int originalImageCount = images.size();
    Point location = gallery.getLocation();
    Point center = gallery.getCenter();

    TouchActions actions = new TouchActions(driver);
    actions.flick(gallery, -10, center.y - location.y, 1000).perform();

    assertNotEquals(originalImageCount, gallery.findElementsByClassName("android.widget.ImageView").size());
}

From source file:io.selendroid.nativetests.NativeElementInteractionTest.java

License:Apache License

@Test
public void shouldLongPressOnElement() {
    openStartActivity();/*w  w  w.java2  s.c  om*/
    WebElement button = driver().findElement(By.id("buttonTest"));
    TouchActions longPress = new TouchActions(driver()).longPress(button);
    longPress.perform();
    WebElement text = driver().findElement(By.partialLinkText("Long Press Tap"));
    Assert.assertNotNull(text);
    // TODO ddary this is essential, not perfect. must be refactored
    driver().findElement(By.id("button1")).click();
}

From source file:io.selendroid.nativetests.NativeElementInteractionTest.java

License:Apache License

@Test
public void shouldTapOnElement() {
    openStartActivity();/*  w  ww  .  j  ava 2  s  .  c o m*/
    WebElement button = driver().findElement(By.id("buttonTest"));
    TouchActions longPress = new TouchActions(driver()).singleTap(button);
    longPress.perform();
    WebElement text = driver().findElement(By.partialLinkText("end the activity"));
    Assert.assertNotNull(text);
    // TODO ddary this is essential, not perfect. must be refactored
    driver().findElement(By.id("button2")).click();
}