简体   繁体   中英

Cannot swipe on appium iOS test

In the documentation, appium presents the following option for java:

JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Double> swipeObject = new HashMap<String, Double>();
swipeObject.put("startX", 0.01);
swipeObject.put("startY", 0.5);
swipeObject.put("endX", 0.95);
swipeObject.put("endY", 0.5);
swipeObject.put("duration", 1.8);
js.executeScript("mobile: swipe", swipeObject);

I integrated this in my test, but after navigating to the screen where swipe would be available, the method with swipe won't perform the action... In the failure exception panel I receive the following error: "org.openqa.selenium.WebDriverException: Not yet implemented".

I want to swipe from left to right, but did not find another solution yet...

UPDATE: I have managed to swipe by using the following code:

HashMap scrollObject = new HashMap();{{
    scrollObject.put("direction", "left");
}};
((RemoteWebDriver) driver).executeScript("mobile: scroll", scrollObject);

The problem is, that it will only swipe once, even if used multiple times... any ideas on how to solve this?

如何使用IOSDriver(驱动程序)并调用以下命令:

    driver.swipe(100, 100, 500, 500, 500);

please refer detailed RCA of this issue with solution

Issue is for iOS appium java client had implmeneted swipe function differently!

for Android it stands with their parameter names endx and endy which are end point coordinates!

But for iOS they are deltaX and deltaY if named correctly.

in nutshell,

Positive endx = Right direction and magnitude of endx defines swipe size
Negative endx = Left direction and magnitude of endx defines swipe size
Positive endy = Down direction and magnitude of endy defines swipe size
Negative endy = UP direction and magnitude of endy defines swipe size

StartX and StartY are coordinates of your start point of the stroke!

Lets take example

1. swipe(100,200,10,20,300) => swipe starting from Point (100,200) and end at Point (110,220) which means finger would move Right lower side fro current position
2. swipe(100,200,-10,20,300) => swipe starting from Point (100,200) and end at Point (90,220) which means finger would move Left lower side from current position
3. swipe(100,200,10,-20,300)=> swipe starting from Point (100,200) and end at Point (110,180) which means finger would move Right Upper side from current position
4. swipe(100,200,-10,-20,300)=> swipe starting from Point (100,200) and end at Point (90,180) which means finger would move Left Upper side from current position

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM