【发布时间】:2021-10-05 03:56:09
【问题描述】:
【问题讨论】:
标签: java android automation android-emulator appium
【问题讨论】:
标签: java android automation android-emulator appium
Appium 中有一个功能可以按图像查找元素。 Appium Pro平台上有一篇为此写的文章:https://appiumpro.com/editions/32-finding-elements-by-image-part-1。
创建图像: 它接受 base64 图像来搜索元素,您可以通过制作球的图像并将其放在 main/resources 文件夹中来做到这一点。使用正确的方法,您可以创建 base64:
private String getReferenceImageB64() throws URISyntaxException, IOException {
URL refImgUrl = getClass().getClassLoader().getResource("Edition031_Reference_Image.png");
File refImgFile = Paths.get(refImgUrl.toURI()).toFile();
return Base64.getEncoder().encodeToString(Files.readAllBytes(refImgFile.toPath()));
}
getLocation():一旦成功找到图像并可以引导元素,就可以使用 .getLocation() 方法。这在文档中有所描述:http://appium.io/docs/en/advanced-concepts/image-elements/。
【讨论】: