sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #29454
[Question #258381]: JavaSwing - ActionPerformed button - Implements Runnable - Sikuli actions not being performed
New question #258381 on Sikuli:
https://answers.launchpad.net/sikuli/+question/258381
Hi,
I am writing this small java swing application in Eclipse Luna, in which I am calling some sikuli actions to be performed from a class that implements "runnable" when a button on the java GUI is clicked.
-->The following is how I call and pass parameters the runnable class from the button:
ClassThread ct = new ClassThread(driver, field1.getText(), field2.getText(), field3.getText(), field4.getText(), field5.getText());
new Thread(ct).start();
-->The below is how I wrote the runnable class:
public class ExtractionThread implements Runnable {
WebDriver driver;
String field1;
String field2;
String field3;
String field4;
String field5;
public ExtractionThread(WebDriver driver, String field1, String field2, String field3, String field4, String field5) {
this.driver = driver;
this.field1 = field1;
this.field2 = field2;
this.field3 = field3;
this.field4 = field4;
this.field5 = field5;
}
@Override
public void run() {
//DECLARE VARIABLES.
final float similarity = (float) 0.8;
final int timeout = 5;
final Screen screen = new Screen();
final Pattern img1 = new Pattern("img/img1.png");
final Pattern img2 = new Pattern("img/img2.png");
final Pattern img3 = new Pattern("img/img3.png");
final Pattern img4 = new Pattern("img/img4.png");
final Pattern img5 = new Pattern("img/img5.png");
//Enter text in field1.
driver.findElement(By.name("fieldName1")).sendKeys(field1);
//Enter text in field2.
driver.findElement(By.name("fieldName2")).sendKeys(field2);
//Click on "Img1".
try {
screen.click(img1);
}
catch (FindFailed e) {
e.printStackTrace();
}
//WAIT FOR IMG2 TO BE SHOW UP ON SCREEN.
while (screen.exists(img2.similar(similarity), timeout) == null) {
screen.wait(2.0);
}
//CLICK ON LINK.
driver.findElement(By.linkText("Link")).click();
//WAIT FOR THE "img3" TO SHOW UP ON SCREEN.
while (screen.exists(img3.similar(similarity), timeout) == null) {
screen.wait(2.0);
}
//ENTER text and click on img4.
try {
screen.type(this.field3);
screen.click(img4, 0);
}
catch (FindFailed e) {
e.printStackTrace();
}
//WAIT UNTIL THE "ABORT SCAN" BUTTON DISAPPEARS: SIKULI.
while (screen.exists(img5.similar(similarity), timeout) == null) {
screen.wait(2.0);
}
}
}
--> Now, the very first time I ran (executed) the program, the SIKULI actions were successfully performed, everything worked just perfectly fine. But when I wanted to execute a second time, the SIKULI part of it did not work at all. All the application does is launches the web browser on the expected URL (which is done by the selenium-java webdriver), but none of the SIKULI actions are performed.
I am puzzled as to what could be causing this behavior. Could someone please advice on this? I am really stuck here, I have not idea how to tackle this situation.
-->Could this be related to the thread I am starting?
Any guidance with this would be greatly appreciated.
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.