我是移动自动化的新手,它试图弄清楚如何将列表中的某些元素放入视图中并对其进行点击。
so far I did it for Android where only the elements are visible when it in-view so we can use scrollToView for them and then pick those if you find them on one on view
however in iOS I can see all the element in Appium even though they are not in the view but problem is I can't tap and scroll to that particular element
是否可以使所有元素的列表然后通过循环到子元素滚动到该特定元素的视图?以下给出的代码在Android上运行正常,但在iOS上运行不正常 这是我的相同代码,适用于android系统。
if(!isElementPresent(by("label.details_key",ImmutableMap.of("index","2"))))
scrollToMyView;
Private void scrollToMyView()
{
Dimension dimensions = getDriver().manage().window().getSize();
int Startpoint = (int) (dimensions.getHeight() * 0.7);
int scrollEnd = (int) (dimensions.getHeight() * 0.3);
int mid = (int) (dimensions.getWidth() * 0.5);
new TouchAction(getDriver()).press(PointOption.point(mid, Startpoint)).waitAction(WaitOptions.waitOptions(Duration.ofMillis(1000))).moveTo(PointOption.point(mid, scrollEnd)).release().perform();
label("scroll");
hardWait(2000);
}
这个我在iOS上尝试过的版本...但是无法正常工作,为什么我有任何解决方法?
public boolean swipeToDirection_iOS_XCTest(MobileElement el, String direction) {
try {
JavascriptExecutor js = (JavascriptExecutor) getDriver();
HashMap<String, String> swipeObject = new HashMap<String, String>();
if (direction.equals("d")) {
swipeObject.put("direction", "down");
} else if (direction.equals("u")) {
swipeObject.put("direction", "up");
} else if (direction.equals("l")) {
swipeObject.put("direction", "left");
} else if (direction.equals("r")) {
swipeObject.put("direction", "right");
}
swipeObject.put("element", el.getId());
js.executeScript("mobile:swipe", swipeObject);
return true;
} catch (Exception e) {
return false;
}
}
MobileElement el = getDriver().findElement(by("tab.posted_trans"));
if(swipeToDirection_iOS_XCTest( el, "down"));
getDriver().findElement(by("tab.posted_trans")).click();