【问题标题】:testautomation - Can´t test game on android screentestautomation - 无法在安卓屏幕上测试游戏
【发布时间】:2018-04-23 17:45:38
【问题描述】:

我想做的是通过图像在android屏幕上“单击”/“触摸”,因为我想测试一个游戏,而这个游戏没有任何xpath。 如果我不能使用图像识别,那么我至少想使用坐标在屏幕上“点击”。

但到目前为止,这些选项都没有对我有用。 我已经到这一步了。现在我使用 Appium 驱动程序。

在桌面上使用图像识别:

public void playGame() 抛出 InterruptedException, FindFailed {

    Screen screen = new Screen();
    String imageLibrary = "src/main/resources/automated-tests/images/";
    String skipIntro = imageLibrary + "JackAndTheBeanstalk/skip.PNG";
    String skipInfo = imageLibrary + "JackAndTheBeanstalk/continue.PNG";
    String bet = imageLibrary + "JackAndTheBeanstalk/increaseStakes.PNG";
    String play = imageLibrary + "JackAndTheBeanstalk/play.PNG";
    Thread.sleep(10000);

    if (screen.exists(new Pattern(skipIntro).similar((float) 0.8)) != null) {
        System.out.println("Start playing Jack and the beanstalk");
        Thread.sleep(10000);
        screen.click(new Pattern(skipIntro).similar((float) 0.8));
        screen.click(new Pattern(skipIntro).similar((float) 0.8));
        screen.click(new Pattern(skipInfo).similar((float) 0.8));
        screen.click(new Pattern(bet).similar((float) 0.8));
        screen.click(new Pattern(play).similar((float)0.8));
    }
}

此图像识别在桌面上运行良好。我的目标是做到这一点,但在 android 上!但是点击方法不适用于android,只能在桌面上使用。我听说您可以使用点击、执行触摸操作和按下,但我不知道如何使用它们。

在安卓上使用新闻:

TouchAction action = new TouchAction(driver); action.press(10, 0).moveTo(22,33).release().perform();

这里的问题是我不知道如何为 android 获取正确的坐标。

有没有人尝试在 android 上测试自动化手机游戏/或类似的东西,或在 android 上使用图像识别或在 android 上使用坐标?或者你有没有使用不同的策略在 android 或其他设备上测试自动化?

提前致谢!

【问题讨论】:

    标签: java android testing automation appium


    【解决方案1】:

    不清楚您使用什么库进行图像识别(您导入什么以使用Screen 类?)。

    但很明显,只有 Appium 不足以对其进行测试。

    您可以研究Appium + Sikuli APIAppium+OpenCV 原型。

    到目前为止的几个链接:

    Appium+Sikuli

    Appium+OpenCV+Akaze

    【讨论】:

    • 我使用 import org.sikuli.script.Screen;但是在两个链接中,“点击”功能都不起作用。所以我有点困惑如何正确使用 Appium 的图像识别
    • 查看我发布的链接,第一个是如何使用Sikuli API + Appium。您的问题没有确切的答案,因为它更笼统,并且对于每个游戏应用程序,可能有不同的图像识别工具是最佳选择。试试我发布的链接,如果有什么适合你的,请告诉我。
    猜你喜欢
    • 1970-01-01
    • 2014-04-19
    • 1970-01-01
    • 2011-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-30
    相关资源
    最近更新 更多