Class: Selenium::WebDriver::Chromium::Options
- Defined in:
- rb/lib/selenium/webdriver/chromium/options.rb
Direct Known Subclasses
Constant Summary collapse
- CAPABILITIES =
{args: 'args', binary: 'binary', local_state: 'localState', prefs: 'prefs', detach: 'detach', debugger_address: 'debuggerAddress', exclude_switches: 'excludeSwitches', minidump_path: 'minidumpPath', emulation: 'mobileEmulation', perf_logging_prefs: 'perfLoggingPrefs', window_types: 'windowTypes', android_package: 'androidPackage', android_activity: 'androidActivity', android_device_serial: 'androidDeviceSerial', android_use_running_app: 'androidUseRunningApp'}.freeze
Constants inherited from Options
Options::GRID_OPTIONS, Options::W3C_OPTIONS
Instance Attribute Summary collapse
-
#extensions ⇒ Object
NOTE: special handling of ‘extensions’ to validate when set instead of when used.
-
#logging_prefs ⇒ Object
Returns the value of attribute logging_prefs.
-
#profile ⇒ Object
Returns the value of attribute profile.
Attributes inherited from Options
Instance Method Summary collapse
-
#add_argument(arg) ⇒ Object
Add a command-line argument to use when starting Chrome.
-
#add_emulation(**opts) ⇒ Object
Add emulation device information.
-
#add_encoded_extension(encoded) ⇒ Object
Add an extension by Base64-encoded string.
-
#add_extension(path) ⇒ Object
Add an extension by local path.
-
#add_preference(name, value) ⇒ Object
Add a preference that is only applied to the user profile in use.
-
#enable_android(package: 'com.android.chrome', serial_number: nil, use_running_app: nil, activity: nil) ⇒ Object
Enables mobile browser use on Android.
-
#initialize(profile: nil, **opts) ⇒ Options
constructor
Create a new Options instance.
Methods inherited from Options
#==, #add_option, #as_json, chrome, edge, firefox, ie, safari, set_capabilities
Constructor Details
#initialize(profile: nil, **opts) ⇒ Options
Create a new Options instance.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'rb/lib/selenium/webdriver/chromium/options.rb', line 70 def initialize(profile: nil, **opts) super(**opts) @profile = profile @options = {args: [], prefs: {}, emulation: {}, extensions: [], local_state: {}, exclude_switches: [], perf_logging_prefs: {}, window_types: []}.merge(@options) @logging_prefs = .delete(:logging_prefs) || {} @encoded_extensions = @options.delete(:encoded_extensions) || [] @extensions = [] @options.delete(:extensions).each { |ext| validate_extension(ext) } end |
Instance Attribute Details
#extensions ⇒ Object
NOTE: special handling of ‘extensions’ to validate when set instead of when used
44 45 46 |
# File 'rb/lib/selenium/webdriver/chromium/options.rb', line 44 def extensions @extensions end |
#logging_prefs ⇒ Object
Returns the value of attribute logging_prefs.
24 25 26 |
# File 'rb/lib/selenium/webdriver/chromium/options.rb', line 24 def logging_prefs @logging_prefs end |
#profile ⇒ Object
Returns the value of attribute profile.
24 25 26 |
# File 'rb/lib/selenium/webdriver/chromium/options.rb', line 24 def profile @profile end |
Instance Method Details
#add_argument(arg) ⇒ Object
Add a command-line argument to use when starting Chrome.
143 144 145 |
# File 'rb/lib/selenium/webdriver/chromium/options.rb', line 143 def add_argument(arg) @options[:args] << arg end |
#add_emulation(**opts) ⇒ Object
Add emulation device information
181 182 183 |
# File 'rb/lib/selenium/webdriver/chromium/options.rb', line 181 def add_emulation(**opts) @options[:emulation] = opts end |
#add_encoded_extension(encoded) ⇒ Object
Add an extension by Base64-encoded string.
129 130 131 |
# File 'rb/lib/selenium/webdriver/chromium/options.rb', line 129 def add_encoded_extension(encoded) @encoded_extensions << encoded end |
#add_extension(path) ⇒ Object
Add an extension by local path.
100 101 102 |
# File 'rb/lib/selenium/webdriver/chromium/options.rb', line 100 def add_extension(path) validate_extension(path) end |
#add_preference(name, value) ⇒ Object
Add a preference that is only applied to the user profile in use.
158 159 160 |
# File 'rb/lib/selenium/webdriver/chromium/options.rb', line 158 def add_preference(name, value) @options[:prefs][name] = value end |
#enable_android(package: 'com.android.chrome', serial_number: nil, use_running_app: nil, activity: nil) ⇒ Object
Enables mobile browser use on Android.
197 198 199 200 201 202 |
# File 'rb/lib/selenium/webdriver/chromium/options.rb', line 197 def enable_android(package: 'com.android.chrome', serial_number: nil, use_running_app: nil, activity: nil) @options[:android_package] = package @options[:android_activity] = activity unless activity.nil? @options[:android_device_serial] = serial_number unless serial_number.nil? @options[:android_use_running_app] = use_running_app unless use_running_app.nil? end |