Class: Selenium::WebDriver::Firefox::Options
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Firefox::Options
- Defined in:
- lib/selenium/webdriver/firefox/options.rb
Constant Summary collapse
- KEY =
'moz:firefoxOptions'.freeze
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#binary ⇒ Object
Returns the value of attribute binary.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#prefs ⇒ Object
readonly
Returns the value of attribute prefs.
-
#profile ⇒ Object
Returns the value of attribute profile.
Instance Method Summary collapse
-
#add_argument(arg) ⇒ Object
Add a command-line argument to use when starting Firefox.
-
#add_option(name, value) ⇒ Object
Add a new option not yet handled by these bindings.
-
#add_preference(name, value) ⇒ Object
Add a preference that is only applied to the user profile in use.
- #as_json ⇒ Object private
-
#headless! ⇒ Object
Run Firefox in headless mode.
-
#initialize(**opts) ⇒ Options
constructor
Create a new Options instance, only for W3C-capable versions of Firefox.
Constructor Details
#initialize(**opts) ⇒ Options
Create a new Options instance, only for W3C-capable versions of Firefox.
43 44 45 46 47 48 49 50 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 43 def initialize(**opts) @args = Set.new(opts.delete(:args) || []) @binary = opts.delete(:binary) @profile = opts.delete(:profile) @log_level = opts.delete(:log_level) @prefs = opts.delete(:prefs) || {} @options = opts.delete(:options) || {} end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
22 23 24 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 22 def args @args end |
#binary ⇒ Object
Returns the value of attribute binary.
23 24 25 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 23 def binary @binary end |
#log_level ⇒ Object
Returns the value of attribute log_level.
23 24 25 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 23 def log_level @log_level end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
22 23 24 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 22 def @options end |
#prefs ⇒ Object (readonly)
Returns the value of attribute prefs.
22 23 24 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 22 def prefs @prefs end |
#profile ⇒ Object
Returns the value of attribute profile.
22 23 24 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 22 def profile @profile end |
Instance Method Details
#add_argument(arg) ⇒ Object
Add a command-line argument to use when starting Firefox.
62 63 64 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 62 def add_argument(arg) @args << arg end |
#add_option(name, value) ⇒ Object
Add a new option not yet handled by these bindings.
77 78 79 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 77 def add_option(name, value) @options[name] = value end |
#add_preference(name, value) ⇒ Object
Add a preference that is only applied to the user profile in use.
92 93 94 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 92 def add_preference(name, value) prefs[name] = value end |
#as_json ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 135 def as_json(*) opts = @options opts[:profile] = @profile.encoded if @profile opts[:args] = @args.to_a if @args.any? opts[:binary] = @binary if @binary opts[:prefs] = @prefs unless @prefs.empty? opts[:log] = {level: @log_level} if @log_level {KEY => opts} end |
#headless! ⇒ Object
Run Firefox in headless mode.
104 105 106 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 104 def headless! add_argument '-headless' end |