Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I have a Selenium WebDriver test where I enter some text into a text input box

    var input_Note = Driver.Instance.FindElement(By.Id("note"));

I then attempt to click on the Save button, but it does not work. I was previously using Coded UI where there is a SetFocus element that points the focus towards whichever element you are targeting. Is there something similar in Selenium?

var button_Save = Driver.Instance.FindElement(By.Id("save"));

I think the problem is with the JavaScript on my page. My application can be slow and unpredictable. I tried telling it to wait until a certain field was not empty, but that didn't seem to work very well. Does anyone have any suggestions on how to handle this

share|improve this question
is there an action that occurs with the button once text has been entered? Are you getting any errors when the click action is performed? –  Dan Snell Mar 24 at 17:19
Hi Dan, yes. When the user enters text into that radio button, another text input gets auto-filled, which can sometimes take a second or two. I have tried using explicit waits, but no luck. Do you have any other suggestions? –  user2917239 Mar 24 at 18:29
Did you try click() instead of Submit()? UPDATE: Also you can try to wait for element to be clickable. Please find the expected conditions document here –  haraprasadj Mar 27 at 6:46
are the explict waits firing correctly or timing out? Can you provide an segment of the html code for the page? –  Dan Snell Mar 27 at 23:39

1 Answer 1

You probably need to use a Selenium JavascriptExecutor and call the command to get focus using JavaScript. If your Firefox was in non-native selenium events mode, then this would make sense. I would try Selenium 2.40.0 with Firefox 27 though, with native events enabled, just to see what happens, otherwise use the JavascriptExecutor as a workaround. I have to use this method to get focus on new windows sometimes because Selenium wont do it.

share|improve this answer
Hi Djangofan, I am using the newest version of Firefox and Selenium WebDriver. Do you know a good resource to learn about using the JavascriptExecutor? Appreciate the help –  user2917239 Mar 24 at 18:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.