【发布时间】:2014-09-03 01:39:08
【问题描述】:
当我尝试使用 java web 驱动程序和 sikuli 使用 flex 自动化一个网站应用程序时,在使用以下代码单击按钮后,我收到错误“java.lang.IllegalThreadStateException: Cannot call method from the event dispatcher thread”
public static void clickImage(String folder, String file) throws FindFailed {
Screen screen;
File loc = new File("images/" + folder + "/" + file + ".png");
Pattern image = new Pattern(loc.getAbsolutePath());
screen = new Screen();
if (isImagePresent(image, 20)) {
try{
waitUntilLoadCompletes(folder);
screen.click(image,0);//This method is throwing error
}catch(Exception e){System.out.println("click has some prblm"+e);}
} else {
new Exception(file+"not found");
}
我也收到以下错误 [错误] mouseDown:按钮仍然按下 - 使用所有 看起来它点击了图像,但它没有释放按钮,这意味着它按下了鼠标按钮但没有释放。在释放按钮之前它会抛出我认为的错误
我在上面代码中使用的以下 fn 中使用 sleep
public static boolean isImagePresent( Pattern img, int time) {
Screen screen=new Screen();
int i = 0;
while (i < time) {
try {
System.out.println(screen.exists(img).toString());
return true;
} catch (Exception e) {
System.out.println("waiting for image--- "+i+" seconds");
}
i++;
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
Logger.getLogger(Library.class.getName()).log(Level.SEVERE, null, ex);
}
}
return false;
}
【问题讨论】:
标签: java multithreading selenium webdriver sikuli