如何通过Cordova mfilechooser插件触发滚动内存文件浏览器

问题描述 投票:0回答:1

我想在 cordova andoird 应用程序中选择一个文件,该应用程序使用 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();
android cordova appium
1个回答
2
投票

以下代码可用于在浏览器屏幕中滚动页面。

我们可以在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();
© www.soinside.com 2019 - 2024. All rights reserved.