簡體   English   中英

無法在Appium iOS測試上滑動

[英]Cannot swipe on appium iOS test

在文檔中,appium為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);

我將其集成到了測試中,但是在導航到可以進行滑動的屏幕之后,使用滑動的方法將無法執行操作...在失敗異常面板中,我收到以下錯誤:“ org.openqa.selenium。 WebDriverException:尚未實現”。

我想從左向右滑動,但還沒有找到其他解決方案...

更新:我已經設法通過使用以下代碼來刷卡:

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

問題是,即使多次使用,它也只會滑動一次...關於如何解決此問題的任何想法?

如何使用IOSDriver(驅動程序)並調用以下命令:

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

請參考此問題的詳細RCA和解決方案

問題是iOS appium java客戶端具有不同的滑動功能!

對於Android,其參數名稱為endx和endy,它們是端點坐標!

但是對於iOS,如果命名正確,則分別為deltaX和deltaY。

簡而言之,

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和StartY是筆畫起點的坐標!

讓我們舉個例子

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM