【问题标题】:How can i make swipe in mobile web page using selendroid webdriver?如何使用 selendroid webdriver 在移动网页中滑动?
【发布时间】:2015-03-23 09:13:20
【问题描述】:
  1. 我已尝试使用以下编码来滑动移动页面。
  2. 运行测试用例时,滑动操作没有发生,我也没有收到任何错误消息。
  3. 如何在左右两侧滑动,反之亦然。

    1. //Swipe Right to Left side of the Media Viewer First Page
                    WebElement firstPages = driver.findElement(By.id("media-list"));
                    TouchActions flick = new TouchActions(driver).flick(firstPages,-100,0,0);
                    flick.perform();
    
    2. //perform swipe gesture
                   TouchActions swipe = new TouchActions(driver).flick(0, -20);
                   swipe.perform();
    

    3.public static void swipe(WebDriver driver) {

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

【问题讨论】:

    标签: java selendroid


    【解决方案1】:
     Obtain the start point end point of the object to be swiped by using appium inspector or use settings->developer options->show pointer location to get starting and end point of object to be scrolled and then perform swipe on that co-ordinates with minimum duration of >500 , swipe wont work if u give any value below 500 in duration.        
    
    
    
            self.driver.swipe(start_x=300, start_y=281, end_x=75, end_y=281, duration=500)
            self.driver.implicitly_wait(10)
            self.driver.swipe(start_x=75, start_y=281, end_x=300, end_y=281, duration=500)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多