Skip to content

Commit

Permalink
[rb] add support for EdgeChrome options
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jun 17, 2019
1 parent 4b6de16 commit 0856fe0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
6 changes: 5 additions & 1 deletion rb/lib/selenium/webdriver/chrome/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def add_emulation(**opt)
def as_json(*)
options = super

options['binary'] ||= Chrome.path if Chrome.path
options['binary'] ||= binary_path if binary_path
extensions = options['extensions'] || []
encoded_extensions = options.delete(:encoded_extensions) || []

Expand All @@ -191,6 +191,10 @@ def as_json(*)

private

def binary_path
Chrome.path
end

def encode_extension(path)
File.open(path, 'rb') { |crx_file| Base64.strict_encode64 crx_file.read }
end
Expand Down
22 changes: 3 additions & 19 deletions rb/lib/selenium/webdriver/edge_chrome/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,11 @@ module Selenium
module WebDriver
module EdgeChrome
class Options < Selenium::WebDriver::Chrome::Options
#
# Create a new Options instance.
#
# @example
# options = Selenium::WebDriver::EdgeChrome::Options.new(args: ['start-maximized', 'user-data-dir=/tmp/temp_profile'])
# driver = Selenium::WebDriver.for(:edge_chrome, options: options)
#
# @param [Hash] opts the pre-defined options to create the Chrome::Options with
# @option opts [Array<String>] :args List of command-line arguments to use when starting Chrome
# @option opts [String] :binary Path to the Chrome executable to use
# @option opts [Hash] :prefs A hash with each entry consisting of the name of the preference and its value
# @option opts [Array<String>] :extensions A list of paths to (.crx) Chrome extensions to install on startup
# @option opts [Hash] :options A hash for raw options
# @option opts [Hash] :emulation A hash for raw emulation options
#
private

def initialize(**opts)
opts[:binary] ||= EdgeChrome.path
super(**opts)
def binary_path
EdgeChrome.path
end

end # Options
end # EdgeChrome
end # WebDriver
Expand Down

0 comments on commit 0856fe0

Please sign in to comment.