testautomation - 无法在Android屏幕上测试游戏

时间:2017-11-10 13:21:14

标签: java android testing automation appium

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

但到目前为止,这些选项都没有对我有用。 这是我来的。现在我使用Appium Driver。

在桌面上使用图像识别:

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,只适用于桌面。我听说你可以使用tap,performTouchAction而不是按,但我不知道如何使用它们。

在ANDROID上使用新闻:

TouchAction动作=新的TouchAction(驱动程序);             action.press(10,0).moveTo(22,33)。release()。perform();

这里的问题是我不知道如何获得Android的右坐标。

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

提前致谢!

1 个答案:

答案 0 :(得分:0)

它不清楚你用于图像识别的库(你用什么导入来使用Screen类?)。

但显而易见的是,只有Appium还不够来测试它。

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

到目前为止的几个链接:

Appium+Sikuli

Appium+OpenCV+Akaze

相关问题