【问题标题】:Scroll element into view not working on iOS using appium使用appium将元素滚动到视图中不适用于iOS
【发布时间】:2020-02-25 08:14:42
【问题描述】:

我正在尝试使用Appium desktop 1.13java_client 7.0.0iOS 13.1.3 滚动查看iOS 中的元素,但它返回错误:

错误域 = com.facebook.WebDriverAgent Code=1 "未能找到 具有 2 个可见子级的可滚动可见父级"

我已经尝试使用element ID 和 Xpath,但两者都不起作用。对于 Xpath,它不会返回错误,但不会执行滚动操作。

String elementID = ((RemoteWebElement) element).getId();
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("element", elementID);
scrollObject.put("toVisible", "not an empty string");
js.executeScript("mobile: scroll", scrollObject);

预期的结果是屏幕将滚动到指定的元素,但是当我使用 Xpath 时它没有滚动而没有任何错误,而当我使用 elementID 时它返回一个错误

【问题讨论】:

    标签: java scroll appium-ios


    【解决方案1】:

    iOS的滚动command好像是

    driver.executeScript("mobile: scroll", ImmutableMap.of("direction", "down"));
    
    
    

    你应该试试这个:

    void Rolldown ():
       Map<String, Object> args = new HashMap<>();
       args.put("direction", "down");
       driver.executeScript("mobile: scroll", arg);
    
    while (true):
       //Use wait explicit to detect if element exist. If not 
       // Rolldown()
       boolean exist = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( "element")));
       if (!exist)
          Rolldown();
    
    
    

    【讨论】:

      【解决方案2】:

      我有同样的问题,我做了这些:

      1. npm i appium-webdriveragent-driver
      2. 下载https://github.com/facebook/WebDriverAgent然后运行 ./Scripts/bootstrap.sh
      3. 从我的模拟器中删除 webdriver 代理应用并重新运行测试用例

      【讨论】:

      • 谢谢,但我仍然遇到上述问题
      猜你喜欢
      • 2016-12-09
      • 2016-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-23
      • 2020-10-01
      • 1970-01-01
      • 2013-12-26
      相关资源
      最近更新 更多