【问题标题】:How to perform Swipe left on iOS device using Appium如何使用 Appium 在 iOS 设备上向左滑动
【发布时间】:2016-10-07 12:50:27
【问题描述】:

我想使用 appium 在特定的 xpath 上向左滑动。有没有我能做到的。

【问题讨论】:

    标签: javascript java selenium selenium-webdriver appium


    【解决方案1】:

    对于上述情况,请执行以下操作:

    WebElement elem = driver.findElementByXPath("//ur elem xpath");
    int x = elem.getLocation().getX();
    int y = elem.getLocation().getY();
    
    TouchAction action = new TouchAction(driver);
     action.longPress(x+5,y+5).waitAction(3000).moveTo(100,0).perform().release();
    

    告诉我会发生什么

    【讨论】:

    • 我正在尝试为特定领域做这件事。有什么办法可以使用 xpath 或 id 来做到这一点
    • 这是什么领域?你能更详细地解释一下你的要求吗?
    • 我已经更新了上面的查询。我在测试 1 字段向左滑动
    • 它正在刷整个屏幕
    • 好的,我想你需要手动长按 Test1 才能滑动,ryt?
    【解决方案2】:

    @noor 这对我有用

    JavascriptExecutor js = (JavascriptExecutor) driver;
        HashMap<String, Double> swipeObject = new HashMap<String, Double>();
            swipeObject.put("startX", 279.2);
            swipeObject.put("startY", 93.1);
            swipeObject.put("endX", 136.1);
            swipeObject.put("endY", 92.6);
            swipeObject.put("duration", 3.0);
            js.executeScript("mobile: flick", swipeObject);
    

    【讨论】:

      猜你喜欢
      • 2019-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-25
      • 1970-01-01
      • 2019-06-16
      • 1970-01-01
      • 2012-08-02
      相关资源
      最近更新 更多