简体   繁体   English

如何使用Sikuli Java API声明屏幕(不是Sikuli脚本)

[英]How to assert a screen with Sikuli java API(Not Sikuli script)

In Sikuli script, we have different ways of asserting like Screen.exists(a.png) etc for image assertion. 在Sikuli脚本中,我们有不同的断言方式,例如Screen.exists(a.png)等用于断言。 But can someone please tell me how to assert an application screen with a screenshot file. 但是有人可以告诉我如何使用屏幕截图文件声明应用程序屏幕。

My requirement is that, I'm logging into a windows application, and after logging in I want to verify the screen that appears with a screenshot file(.png) captured earlier. 我的要求是,我要登录Windows应用程序,登录后要验证显示的屏幕,其中包含先前捕获的屏幕快照文件(.png)。

Sikuli api 1.0.2 Windows 7 64 bit Sikuli API 1.0.2 Windows 7 64位

This should help you- 这应该可以帮助您-

int timeout = <Specify timeout in millis>;
String imagePath = <give the path of your screenshot image here>;
ImageTarget target = new ImageTarget(new File(imagePath));
ScreenRegion result = desktop.wait(target,timeout);

Here if result is null after the timeout, it would mean the image found in the application does not match the one at the path of the screenshot you would have mentioned. 如果超时后结果为null,则表示在应用程序中找到的图像与您提到的屏幕快照路径中的图像不匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM