Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

click

selenium

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!

like image 255
user2029646 Avatar asked Oct 26 '25 07:10

user2029646


1 Answers

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);
like image 69
jgode Avatar answered Oct 29 '25 05:10

jgode



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!