【问题标题】:Appium Mobile Automation : How to check the location of bouncing ball in AnimationAppium Mobile Automation:如何在动画中检查弹跳球的位置
【发布时间】:2021-10-05 03:56:09
【问题描述】:

我正在测试 appium 提供的演示 apk 应用程序,其中我正在测试反向动画。 单击“播放”和“反转”按钮,球会上下移动。是否可以检查球是否已到达某个坐标。球没有定位器

【问题讨论】:

    标签: java android automation android-emulator appium


    【解决方案1】:

    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/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-14
      • 1970-01-01
      • 1970-01-01
      • 2012-03-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多