我想在 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();
以下代码可用于在浏览器屏幕中滚动页面。
我们可以在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();