[英]Sikuli screen.wait not working
I'm using sikuli in Java, current IDE is eclipse oxygen 我在Java中使用sikuli,当前的IDE是蚀氧
this is my pom.xml 这是我的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Automation</groupId>
<artifactId>SeleniumTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>LATEST</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
</project>
my code like this 我的代码是这样的
@Test(description = "spin test")
public void spinLongPeriod() throws Exception {
int wait_time, last = 5000;
caseReq.addAll(Arrays.asList(
new Pattern("src/test/resources/spin.png"),
new Pattern("src/test/resources/spin-stop.png"),
new Pattern("src/test/resources/spin-disabled.png"),
new Pattern("src/test/resources/good-luck.png"),
new Pattern("src/test/resources/spin-auto.png")
));
screen.wait(caseReq.get(0), 10);
while (last >= 0) {
screen.click(caseReq.get(0));
screen.click(caseReq.get(1));
wait_time = 60;
screen.wait(caseReq.get(0), wait_time);
// while (wait_time >= 0) {
// Thread.sleep(1000);
// wait_time -= 1000;
// if (screen.exists(caseReq.get(0)) != null) {
// break;
// }
// }
--last;
}
}
I abandoned the sikuli Screen.wait method once because it failed 我一次放弃了sikuli Screen.wait方法,因为它失败了
By using the "while + Thread.sleep" solution for a while 通过使用“ while + Thread.sleep”解决方案一段时间
But not this time, error message came out 但是这次不是错误消息了
FindFailed: can not find P(src/test/resources/spin-stop.png) S: 0.7 in S(0)[0,0 1920x1080]
I'd sought the solution from Internet for a long time... 我很久以来一直在互联网上寻求解决方案...
Any suggestion? 有什么建议吗?
I use next method 我用下一种方法
private boolean exists(Pattern img, int sec) {
try {
window.wait(img, sec);
return true;
} catch (FindFailed exeption) {
return false;
}
}
And it works well. 而且效果很好。 If some image can't be found, try to adjust it by .similar((float)0.5);
如果找不到某些图像,请尝试通过.similar((float)0.5);进行调整。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.