代码之家  ›  专栏  ›  技术社区  ›  Mohammed H

如何滚动cordova mfilechooser插件触发的内存文件浏览器

  •  1
  • Mohammed H  · 技术社区  · 8 年前

    我想在Cordova和Oird应用程序中选择一个文件,它使用Cordova mFileChooser插件来浏览文件。我用了下面的appium代码。但滚动并没有发生。

    AndroidElement list = (AndroidElement) driver
       .findElement(By.id("android:id/list"));
    MobileElement list_group = list.findElement(
         MobileBy.AndroidUIAutomator(
         "(new UiScrollable(new UiSelector)).scrollIntoView(" +
        "new UiSelector.text(\"importSample\"));"
    ));
    list_group.getLocation();
    list_group.click();
    
    1 回复  |  直到 8 年前
        1
  •  2
  •   Akash S    8 年前

    下面的代码将用于滚动浏览屏幕。

    我们可以在Selenium中使用Dimension类:import org.openqa.selenium.dimension;

    代码:

    Dimension size = driver.manage().window().getSize();
    int x = size.getWidth() / 2;
    int startY = (int) (size.getHeight() * 0.10);
    int endY = (int) (size.getHeight() * 0.90);
    TouchAction ta = new TouchAction(driver);
    ta.press(x, endY).waitAction(Duration.ofSeconds(1)).moveTo(x, startY).release();
    ta.perform();