user2029646
user2029646

Reputation: 41

Need to change focus to another text box before buttons are activated

I am entering data into text fields in a browser via "type" command. In order for the Save and Cancel buttons to be activated (not grayed out), I need to click in another text field to change focus. This works manually, but I can't seem to figure out how to do it programmatically. I have tried click, clickAt, doubleClick, mouseOver/click/mouseOUt, mouseDown/mouseUp, focus, fireEvent ... all without luck. Thanks for any suggestions!

Upvotes: 4

Views: 13836

Answers (1)

jgode
jgode

Reputation: 1879

Does tabbing out of the input field enable the buttons? If so, maybe you can just do:

WebElement element = driver.findElement(By.id("your_input_field"));
element.sendKeys(Keys.TAB);

Upvotes: 11

Related Questions