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?
To enable or disable JavaScript on an Android mobile device, you need to access the browser settings. As there are many different browsers on Android devices, you may need to use some intuition to access the settings.
Selenium is an open-source automation testing tool that supports a number of scripting languages like C#, Java, Perl, Ruby, JavaScript, etc. Depending on the application to be tested, one can choose the script accordingly.
Yes, It is possible. But a different way. You first need to look into the link
Selenium::WebDriver::Firefox::Profile #[]=(key, value)
.
JavaScript settings
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With