[Java] Junit: How to avoid false positive using App.focus
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(
if (focusResult != null) {
pass = true;
}
if (pass) {
return true;
}
else {
+ windowName);
}
numberOfT
}
while (numberOfTries < 4);
return false;
}
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Can you help with this problem?
Provide an answer of your own, or ask Vince for more information if necessary.