jmcwhinney
11 years agoContributor
Focus Issues clicking JButton in Java Application
Below is my code to click a given button:
function ClickButton(TheButton){
//Works Intermittantly
TheButton.grabFocus();
aqUtils.Delay(1000);
TheButton.Click();
}
If i click the parent window with my mouse before starting the test, the code works.
However, if I do not, it seems like the button is clicked, but nothing happens.
My assumption is this has to do with focus.
Is there a way I can ensure the button has focus before clicking it?
Programatically clicking the button twice seems to work, but that approach seems less than Ideal and I think it could cause other problems.
Thanks,
- James