Watir Changing Mozilla Firefox Preferences
WebDriver uses a clean profile for each browser instance, which is why the preferences appear to be "reset". You can tell it to use your default profile:
Watir::Browser.new :firefox, :profile => "default"
or tweak profile preferences programatically before launching the browser:profile = Selenium::WebDriver::Firefox::Profile.new
profile['some.preference'] = true
profile.add_extension "/path/to/some/extension.xpi"
Watir::Browser.new :firefox, :profile => profile
For an example of configuring automatic file downloads, see this section on the Selenium wiki. How to modify the Firefox profile used by Watir-Webdriver
I don't know why, but if I use from_name
method in Selenium class init, then you code is working perfectly:
profile = Selenium::WebDriver::Firefox::Profile.from_name "default"
Ruby gem watir changing Firefox proxy settings without being asked to
Based on the information here, there are 5 different proxy configurations for Firefox:
0
Direct connection, no proxy. (Default in Windows and Mac previous to 1.9.2.4 /Firefox 3.6.4)
[edit]
1
Manual proxy configuration.
[edit]
2
Proxy auto-configuration (PAC).
[edit]
4
Auto-detect proxy settings.
[edit]
5
Use system proxy settings. (Default in Linux; default for all platforms, starting in 1.9.2.4 /Firefox 3.6.4)
It looks like "0" is the one you need. We set that as described on the Watir-Webdriver help page for Firefox:profile = Selenium::WebDriver::Firefox::Profile.new
profile["network.proxy.type"] = 0
browser = Watir::Browser.new :firefox, :profile => profile
All of the profile["lorem ipsum"] type options are listed in the about:config menu URL in Firefox, and are accessed/changed in a similar fashion. Current way of setting language in browsers?
The "intl.accept_languages" is a Chrome preference, so can be passed in as:
Watir::Browser.new :chrome, options: {prefs: {'intl' => {'accept_languages' => 'ES'}}}
Difficulty Clicking a Specific Button in Firefox Using Watir
It is the text property you are looking for, but it is not matching because of the image content which is also in the text of the button. You should probably use a regular expression along the lines of
$browser.button(:text => /Add and Continue/).click
Watir Webdriver(0.9.1) No Longer Opens an Instance of Firefox
Mozilla has introduced a new webdriver, and due to a bug in firefox 47, only the new webdriver works for firefox. However I would suggest permanently switching to the new webdriver either way as support will be fully dropped as of firefox 48.
You can use the new webdriver in ruby using the following:
driver = Selenium::WebDriver.for :firefox, marionette: true
But I don't know if that would make you able to use it in watir as well.As far as I can tell marionette (the new driver) support is not completed yet in watir (I could be wrong), I see this pull request is dealing with it but it is not completed or merged.
It looks to me as if you can do:
browser = Watir::Browser.new :marionette
When the watir project is finished integrating the new driver. watir hang up after new browser
try gem update selenium-webdriver
similar question here
Can not use variable in IRB after var = Watir::Browser.start 'url'
Related Topics
Rails Asset Pipeline and Digest Values
What Is - Gets Is a Directory - Error Message
How to Catch an "Undefined Method '[]' for Nil:Nilclass" Error
How to Stub/Mock a Call to The Command Line with Rspec
Use a String to Access a Local Variable by Name
Download a Carrierwave Upload from S3
How to Specify Regexp Options Using Regexp.Union
Is 'Respond_To_Missing''s Second Argument Useful for Anything
Phusion Passenger with Ruby 1.8 and 1.9
Ruby - Generate All Two Letter Words
Ruby Linkify for Urls in Strings
How to Access Parent/Sibling Module Methods
How to Override a Variable in a Ruby Subclass Without Affecting The Superclass
How to Split a String Containing Both Delimiter and The Escaped Delimiter
How to Handle Single Table Inheritance in Simpleform So a Single Helper Handles All Models
Inspect or Clean Up The Working Tree Error When Installing Ruby 2.1.3 on MAC Os X 10.9.5