1

I am using the script to set the value of the hidden form field variable formContent to the value 'Hello'. Selenium Webdriver doesn't set the value of the hidden form field as it is not visible.

Here is my code:

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("return jQuery('input:hidden[id$=\"formContent\"]').val('Hello');");

I am getting the script is unresponsive. Could you please tell me what I am doing wrong here. The formContent is defined in my xhtml as follows:

<input type="hidden" id="formContent" name="formContent" value="" />

If use the following lines of code, then it is not setting the value of the hidden form field "formContent":

 JavascriptExecutor js = (JavascriptExecutor) driver;
 js.executeScript("jQuery('input:hidden[id$=\"formContent\"]').val('Hello');");

Thanks!

3
  • It would be helpful to know what you intend for the script to do Commented Apr 10, 2012 at 16:25
  • I am using the script to set the value of the hidden form field variable formContent to the value 'Hello'. Selenium Webdriver doesnt set the value of the hidden form field as it is not visible. Commented Apr 10, 2012 at 16:52
  • Please check whether it works with an 'alert'. Commented Apr 10, 2012 at 17:33

1 Answer 1

1

I believe it's a bug with the Firefox webdriver. I experienced something similar when trying to return jQuery objects and described the behavior here: http://code.google.com/p/selenium/issues/detail?id=3756

Try returning something other than a jQuery obj, and it should become responsive again. For example, you could return a boolean value of your executed code by just prefixing it with !! like this:

js.executeScript("return !!jQuery('input:hidden[id$=\"formContent\"]').val('Hello');");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.