Search in sources :

Example 16 with MobileElement

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

the class AndroidSearchingTest method findScrollable.

@Test
public void findScrollable() {
    driver.findElementByAccessibilityId("Views").click();
    MobileElement radioGroup = driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()" + ".resourceId(\"android:id/list\")).scrollIntoView(" + "new UiSelector().text(\"Radio Group\"));");
    assertNotNull(radioGroup.getLocation());
}
Also used : MobileElement(io.appium.java_client.MobileElement) Test(org.junit.Test)

Example 17 with MobileElement

use of io.appium.java_client.MobileElement 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 18 with MobileElement

use of io.appium.java_client.MobileElement 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 MobileElement

use of io.appium.java_client.MobileElement 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 MobileElement

use of io.appium.java_client.MobileElement in project opentest by mcdcorp.

the class ActionsLongPress method run.

@Override
public void run() {
    super.run();
    By locator = this.readLocatorArgument("locator", null);
    Integer xOffset = this.readIntArgument("xOffset", 0);
    Integer yOffset = this.readIntArgument("yOffset", 0);
    Integer x = this.readIntArgument("x", null);
    Integer y = this.readIntArgument("y", null);
    MobileElement element = this.getElement(locator);
    if (locator != null) {
        Point position = element.getLocation();
        Dimension dimension = element.getSize();
        int xCoord = position.x + (dimension.width / 2) + xOffset;
        int yCoord = position.y + (dimension.height / 2) + yOffset;
        AppiumTestAction.getActionsInstance().longPress(PointOption.point(xCoord, yCoord));
    } else if (x != null && y != null) {
        AppiumTestAction.getActionsInstance().longPress(PointOption.point(x, y));
    } else {
        throw new RuntimeException("You must either provide the locator argument of the element to press, " + "or the x and y arguments to indicate the exact coordinates to press at.");
    }
}
Also used : MobileElement(io.appium.java_client.MobileElement) By(org.openqa.selenium.By) Point(org.openqa.selenium.Point) Dimension(org.openqa.selenium.Dimension) Point(org.openqa.selenium.Point)

Aggregations

MobileElement (io.appium.java_client.MobileElement)27 Test (org.junit.Test)12 By (org.openqa.selenium.By)11 Point (org.openqa.selenium.Point)7 TouchAction (io.appium.java_client.TouchAction)6 Dimension (org.openqa.selenium.Dimension)6 MultiTouchAction (io.appium.java_client.MultiTouchAction)4 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)3 PublicAtsApi (com.axway.ats.common.PublicAtsApi)1 MobileOperationException (com.axway.ats.uiengine.exceptions.MobileOperationException)1 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)1 AndroidElement (io.appium.java_client.android.AndroidElement)1 IOSDriver (io.appium.java_client.ios.IOSDriver)1 ElementOption (io.appium.java_client.touch.offset.ElementOption)1 PointOption.point (io.appium.java_client.touch.offset.PointOption.point)1 Rectangle (java.awt.Rectangle)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 AppiumHelper.getCapabilityAsString (org.getopentest.appium.core.AppiumHelper.getCapabilityAsString)1 Config (org.getopentest.util.Config)1