sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #05314
[Question #171260]: [Java] Junit: How to avoid false positive using App.focus
New question #171260 on Sikuli:
https://answers.launchpad.net/sikuli/+question/171260
I'm using Sikuli in Eclipse with Java. I've been able to get the App.focus function to work great but every once in a while it doesn't work. I created a function to check that the focus worked but I'm getting false positives. The function reports back that the window was correctly focused but nothing happens on the screen.
Any suggestions on how to avoid the false positive where the window is not focused but reports back that it was?
My code:
public static boolean ensureFocus(String windowName) throws Exception {
int numberOfTries = 1;
boolean pass = false;
do {
App focusResult = App.focus(windowName);
if (focusResult != null) {
pass = true;
}
if (pass) {
System.out.println("Check number " + numberOfTries + " passed focusing on " + windowName);
return true;
}
else {
System.out.println("Check number " + numberOfTries + " failed trying to focus on "
+ windowName);
}
numberOfTries++;
}
while (numberOfTries < 4);
return false;
}
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.