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