Search in sources :

Example 16 with TouchAction

use of io.appium.java_client.TouchAction in project java-client by appium.

the class AndroidTouchTest method horizontalSwipingTest.

@Test
public void horizontalSwipingTest() {
    Activity activity = new Activity("io.appium.android.apis", ".view.Gallery1");
    driver.startActivity(activity);
    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();
    TouchAction swipe = new TouchAction(driver).press(element(images.get(2), -10, center.y - location.y)).waitAction(waitOptions(ofSeconds(2))).moveTo(element(gallery, 10, center.y - location.y)).release();
    swipe.perform();
    assertNotEquals(originalImageCount, gallery.findElementsByClassName("android.widget.ImageView").size());
}
Also used : MobileElement(io.appium.java_client.MobileElement) Point(org.openqa.selenium.Point) Point(org.openqa.selenium.Point) PointOption.point(io.appium.java_client.touch.offset.PointOption.point) TouchAction(io.appium.java_client.TouchAction) MultiTouchAction(io.appium.java_client.MultiTouchAction) Test(org.junit.Test)

Example 17 with TouchAction

use of io.appium.java_client.TouchAction in project java-client by appium.

the class AndroidTouchTest method pressByCoordinatesTest.

@Test
public void pressByCoordinatesTest() {
    Activity activity = new Activity("io.appium.android.apis", ".view.Buttons1");
    driver.startActivity(activity);
    Point point = driver.findElementById("io.appium.android.apis:id/button_toggle").getLocation();
    new TouchAction(driver).press(point(point.x + 20, point.y + 30)).waitAction(waitOptions(ofSeconds(1))).release().perform();
    assertEquals("ON", driver.findElementById("io.appium.android.apis:id/button_toggle").getText());
}
Also used : Point(org.openqa.selenium.Point) TouchAction(io.appium.java_client.TouchAction) MultiTouchAction(io.appium.java_client.MultiTouchAction) Test(org.junit.Test)

Example 18 with TouchAction

use of io.appium.java_client.TouchAction in project java-client by appium.

the class IOSTouchTest method swipeTest.

@Test
public void swipeTest() {
    MobileElement slider = driver.findElementByClassName("UIASlider");
    Dimension size = slider.getSize();
    ElementOption press = element(slider, size.width / 2 + 2, size.height / 2);
    ElementOption move = element(slider, 1, size.height / 2);
    TouchAction swipe = new TouchAction(driver).press(press).waitAction(waitOptions(ofSeconds(2))).moveTo(move).release();
    swipe.perform();
    assertEquals("0%", slider.getAttribute("value"));
}
Also used : ElementOption(io.appium.java_client.touch.offset.ElementOption) MobileElement(io.appium.java_client.MobileElement) Dimension(org.openqa.selenium.Dimension) TouchAction(io.appium.java_client.TouchAction) MultiTouchAction(io.appium.java_client.MultiTouchAction) Test(org.junit.Test)

Example 19 with TouchAction

use of io.appium.java_client.TouchAction in project java-client by appium.

the class IOSTouchTest method multiTouchTest.

@Test
public void multiTouchTest() {
    MobileElement e = driver.findElementByAccessibilityId("ComputeSumButton");
    MobileElement e2 = driver.findElement(IosUIAutomation(".elements().withName(\"show alert\")"));
    TouchAction tap1 = new TouchAction(driver).tap(tapOptions().withElement(element(e)));
    TouchAction tap2 = new TouchAction(driver).tap(tapOptions().withElement(element(e2)));
    new MultiTouchAction(driver).add(tap1).add(tap2).perform();
    WebDriverWait waiting = new WebDriverWait(driver, 10000);
    assertNotNull(waiting.until(alertIsPresent()));
    driver.switchTo().alert().accept();
}
Also used : MultiTouchAction(io.appium.java_client.MultiTouchAction) MobileElement(io.appium.java_client.MobileElement) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) TouchAction(io.appium.java_client.TouchAction) MultiTouchAction(io.appium.java_client.MultiTouchAction) Test(org.junit.Test)

Example 20 with TouchAction

use of io.appium.java_client.TouchAction in project carina by qaprosoft.

the class MobileUtils method tap.

/**
 * Tap with TouchAction by coordinates with custom duration
 *
 * @param startx int
 * @param starty int
 * @param duration int
 */
public static void tap(int startx, int starty, int duration) {
    TouchAction touchAction = new TouchAction((MobileDriver<?>) DriverPool.getDriver());
    touchAction.press(startx, starty).waitAction(Duration.ofMillis(duration)).release().perform();
}
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