Class: Selenium::WebDriver::Firefox::Options
- Defined in:
- lib/selenium/webdriver/firefox/options.rb
Constant Summary collapse
- KEY =
'moz:firefoxOptions'
- CAPABILITIES =
{binary: 'binary', args: 'args', log: 'log', prefs: 'prefs', env: 'env', android_package: 'androidPackage', android_activity: 'androidActivity', android_device_serial: 'androidDeviceSerial', android_intent_arguments: 'androidIntentArguments'}.freeze
- BROWSER =
'firefox'
Constants inherited from Options
Options::GRID_OPTIONS, Options::W3C_OPTIONS
Instance Attribute Summary collapse
-
#debugger_address ⇒ Object
Returns the value of attribute debugger_address.
-
#profile ⇒ Object
NOTE: special handling of ‘profile’ to validate when set instead of when used.
Attributes inherited from Options
Instance Method Summary collapse
-
#add_argument(arg) ⇒ Object
Add a command-line argument to use when starting Firefox.
-
#add_preference(name, value) ⇒ Object
Add a preference that is only applied to the user profile in use.
-
#enable_android(package: 'org.mozilla.firefox', serial_number: nil, activity: nil, intent_arguments: nil) ⇒ Object
Enables mobile browser use on Android.
-
#initialize(log_level: nil, **opts) ⇒ Options
constructor
Create a new Options instance, only for W3C-capable versions of Firefox.
- #log_level ⇒ Object
- #log_level=(level) ⇒ Object
Methods inherited from Options
#==, #add_option, #as_json, chrome, edge, firefox, ie, safari, set_capabilities
Constructor Details
#initialize(log_level: nil, **opts) ⇒ Options
Create a new Options instance, only for W3C-capable versions of Firefox.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 59 def initialize(log_level: nil, **opts) @debugger_address = opts.delete(:debugger_address) { true } opts[:accept_insecure_certs] = true unless opts.key?(:accept_insecure_certs) super(**opts) @options[:args] ||= [] @options[:prefs] ||= {} # Firefox 129 onwards the CDP protocol will not be enabled by default. Setting this preference will enable it. # https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/. @options[:prefs]['remote.active-protocols'] = 3 @options[:env] ||= {} @options[:log] ||= {level: log_level} if log_level process_profile(@options.delete(:profile)) end |
Instance Attribute Details
#debugger_address ⇒ Object
Returns the value of attribute debugger_address.
24 25 26 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 24 def debugger_address @debugger_address end |
#profile ⇒ Object
NOTE: special handling of ‘profile’ to validate when set instead of when used
41 42 43 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 41 def profile @profile end |
Instance Method Details
#add_argument(arg) ⇒ Object
Add a command-line argument to use when starting Firefox.
86 87 88 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 86 def add_argument(arg) @options[:args] << arg end |
#add_preference(name, value) ⇒ Object
Add a preference that is only applied to the user profile in use.
101 102 103 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 101 def add_preference(name, value) @options[:prefs][name] = value end |
#enable_android(package: 'org.mozilla.firefox', serial_number: nil, activity: nil, intent_arguments: nil) ⇒ Object
Enables mobile browser use on Android.
144 145 146 147 148 149 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 144 def enable_android(package: 'org.mozilla.firefox', serial_number: nil, activity: nil, intent_arguments: nil) @options[:android_package] = package @options[:android_activity] = activity unless activity.nil? @options[:android_device_serial] = serial_number unless serial_number.nil? @options[:android_intent_arguments] = intent_arguments unless intent_arguments.nil? end |
#log_level ⇒ Object
124 125 126 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 124 def log_level @options.dig(:log, :level) end |
#log_level=(level) ⇒ Object
128 129 130 |
# File 'lib/selenium/webdriver/firefox/options.rb', line 128 def log_level=(level) @options[:log] = {level: level} end |