【问题标题】:scroll to element not working in appium driver滚动到在 appium 驱动程序中不起作用的元素
【发布时间】:2020-12-17 00:57:37
【问题描述】:

滚动到在 appium 驱动程序中不起作用的元素。 有没有类似的javascript

 ((JavascriptExecutor) getWebDriver()).executeScript("arguments[0].scrollIntoView();", getWebDriver().findElement(locator)); 

用于网络驱动程序。 我们正在使用

driver.context("WEBVIEW_" + applicationId);

而不是 uiautomator

有什么帮助吗?

【问题讨论】:

    标签: javascript scroll automation appium


    【解决方案1】:

    你可以在 appium 中使用 touchActions 来滚动:

    TouchActions action = new TouchActions(driver);
    action.scroll(element, 10, 100);
    action.perform();
    

    或使用对 2 个元素的引用:

    TouchAction().press(el0).moveTo(el1).release();
    

    【讨论】:

      【解决方案2】:

      您可以使用以下代码。

      ((FindsByAndroidUIAutoamtor<?>)(driver).find_element_by_android_uiautomator('new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains("**Expected text**").instance(0))');
      

      有关 uiautomators 的更多信息,请参阅 https://developer.android.com/reference/androidx/test/uiautomator/UiScrollable

      【讨论】:

      • 这不起作用,因为我们正在使用 Webview driver.context("WEBVIEW_" + applicationId);
      猜你喜欢
      • 2015-11-12
      • 2018-05-16
      • 1970-01-01
      • 1970-01-01
      • 2020-10-01
      • 1970-01-01
      • 2018-01-20
      • 1970-01-01
      • 2016-06-13
      相关资源
      最近更新 更多