Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

For some reason, I've to disable javascript for Firefox (Manually, we do by following steps mentioned http://support.mozilla.org/en-US/kb/javascript-settings-for-interactive-web-pages#w_enabling-and-disabling-javascript). How can this be achieved by Selenium WebDriver using Ruby?

share|improve this question
 
Just a shot in the dark here. Can you try passing false in when you instantiate the driver? –  Travis J Jun 21 '13 at 17:38
 
It doesn't work. –  TDHM Jun 21 '13 at 17:44
 
Sorry, it doesn't seem to cover that case in the documentation, and that was my only guess. –  Travis J Jun 21 '13 at 17:46
 
@TravisJ yes,it is possible. check my answer. –  Arup Rakshit Jun 21 '13 at 19:04
add comment

1 Answer

up vote 2 down vote accepted

Yes, It is possible. But a different way. You first need to look into the link

Once you would visit the link,try the below code :

require 'selenium-webdriver'

profile = Selenium::WebDriver::Firefox::Profile.new
profile["javascript.enabled"] = false

driver = Selenium::WebDriver.for(:firefox, :profile => profile)

profile
# => #<Selenium::WebDriver::Firefox::Profile:0x89c7568
#     @additional_prefs=
#      {"javascript.enabled"=>false, "webdriver_firefox_port"=>7055},
#     @extensions=
#      {:webdriver=>
#        #<Selenium::WebDriver::Firefox::Extension:0x89c6488 # !> previous definition of proxy= was here
#         @path=
#          "/home/kirti/.rvm/gems/ruby-2.0.0-p0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/firefox/extension/webdriver.xpi",
#         @should_reap_root=true>},
#     @load_no_focus_lib=false,
#     @model=nil,
#     @native_events=false,
#     @secure_ssl=false,
#     @untrusted_issuer=true>

Once your browser window will be opened up through the above code,then check the Preferences from Edit->Preferences->content,then you would see that Enable JavaScript: option is unchecked.

Enable JavaScript:

share|improve this answer
1  
Thank you OMG!!! It worked. Thanks for pointing to docs. –  TDHM Jun 24 '13 at 7:32
 
@grm My pleasure to help you.. I spent 1 hours to find the second linked docs.. :)) –  Arup Rakshit Jun 24 '13 at 7:37
add comment

Your Answer

 
discard

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.