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());
}
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());
}
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"));
}
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();
}
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();
}
Aggregations