Search in sources :

Example 11 with TouchAction

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

the class AndroidTouchTest method multiTouchTest.

@Test
public void multiTouchTest() {
    Activity activity = new Activity("io.appium.android.apis", ".view.Buttons1");
    driver.startActivity(activity);
    TouchAction press = new TouchAction(driver).press(element(driver.findElementById("io.appium.android.apis:id/button_toggle"))).waitAction(waitOptions(ofSeconds(1))).release();
    new MultiTouchAction(driver).add(press).perform();
    assertEquals("ON", driver.findElementById("io.appium.android.apis:id/button_toggle").getText());
}
Also used : MultiTouchAction(io.appium.java_client.MultiTouchAction) TouchAction(io.appium.java_client.TouchAction) MultiTouchAction(io.appium.java_client.MultiTouchAction) Test(org.junit.Test)

Example 12 with TouchAction

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

the class IOSTouchTest method tapTest.

@Test
public void tapTest() {
    IOSElement intA = driver.findElementById("IntegerA");
    IOSElement intB = driver.findElementById("IntegerB");
    intA.clear();
    intB.clear();
    intA.sendKeys("2");
    intB.sendKeys("4");
    MobileElement e = driver.findElementByAccessibilityId("ComputeSumButton");
    new TouchAction(driver).tap(tapOptions().withElement(element(e))).perform();
    assertEquals(driver.findElementByXPath("//*[@name = \"Answer\"]").getText(), "6");
}
Also used : MobileElement(io.appium.java_client.MobileElement) TouchAction(io.appium.java_client.TouchAction) MultiTouchAction(io.appium.java_client.MultiTouchAction) Test(org.junit.Test)

Example 13 with TouchAction

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

the class AndroidTouchTest method dragNDropByElementTest.

@Test
public void dragNDropByElementTest() {
    Activity activity = new Activity("io.appium.android.apis", ".view.DragAndDropDemo");
    driver.startActivity(activity);
    WebElement dragDot1 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_1"));
    WebElement dragDot3 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_3"));
    WebElement dragText = driver.findElement(By.id("io.appium.android.apis:id/drag_text"));
    assertEquals("Drag text not empty", "", dragText.getText());
    TouchAction dragNDrop = new TouchAction(driver).longPress(element(dragDot1)).moveTo(element(dragDot3)).release();
    dragNDrop.perform();
    assertNotEquals("Drag text empty", "", dragText.getText());
}
Also used : WebElement(org.openqa.selenium.WebElement) TouchAction(io.appium.java_client.TouchAction) MultiTouchAction(io.appium.java_client.MultiTouchAction) Test(org.junit.Test)

Example 14 with TouchAction

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

the class AndroidTouchTest method dragNDropByElementAndDurationTest.

@Test
public void dragNDropByElementAndDurationTest() {
    Activity activity = new Activity("io.appium.android.apis", ".view.DragAndDropDemo");
    driver.startActivity(activity);
    WebElement dragDot1 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_1"));
    WebElement dragDot3 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_3"));
    WebElement dragText = driver.findElement(By.id("io.appium.android.apis:id/drag_text"));
    assertEquals("Drag text not empty", "", dragText.getText());
    TouchAction dragNDrop = new TouchAction(driver).longPress(longPressOptions().withElement(element(dragDot1)).withDuration(ofSeconds(2))).moveTo(element(dragDot3)).release();
    dragNDrop.perform();
    assertNotEquals("Drag text empty", "", dragText.getText());
}
Also used : WebElement(org.openqa.selenium.WebElement) TouchAction(io.appium.java_client.TouchAction) MultiTouchAction(io.appium.java_client.MultiTouchAction) Test(org.junit.Test)

Example 15 with TouchAction

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

the class AndroidTouchTest method dragNDropByCoordinatesAndDurationTest.

@Test
public void dragNDropByCoordinatesAndDurationTest() {
    Activity activity = new Activity("io.appium.android.apis", ".view.DragAndDropDemo");
    driver.startActivity(activity);
    AndroidElement dragDot1 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_1"));
    AndroidElement dragDot3 = driver.findElement(By.id("io.appium.android.apis:id/drag_dot_3"));
    WebElement dragText = driver.findElement(By.id("io.appium.android.apis:id/drag_text"));
    assertEquals("Drag text not empty", "", dragText.getText());
    Point center1 = dragDot1.getCenter();
    Point center2 = dragDot3.getCenter();
    TouchAction dragNDrop = new TouchAction(driver).longPress(longPressOptions().withPosition(point(center1.x, center1.y)).withDuration(ofSeconds(2))).moveTo(point(center2.x, center2.y)).release();
    dragNDrop.perform();
    assertNotEquals("Drag text empty", "", dragText.getText());
}
Also used : Point(org.openqa.selenium.Point) WebElement(org.openqa.selenium.WebElement) TouchAction(io.appium.java_client.TouchAction) MultiTouchAction(io.appium.java_client.MultiTouchAction) Test(org.junit.Test)

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