diff --git a/rb/build.desc b/rb/build.desc index b1752d29a38da..a974ed5963a56 100644 --- a/rb/build.desc +++ b/rb/build.desc @@ -73,6 +73,9 @@ ruby_library(name = "edge", "lib/selenium/webdriver/edge/**/*.rb", "lib/selenium/webdriver/edge.rb" ], + resources = [ + { "//javascript/webdriver/atoms:getAttribute": "rb/lib/selenium/webdriver/atoms/getAttribute.js"} + ], deps = [":common"] ) diff --git a/rb/lib/selenium/webdriver/chrome/bridge.rb b/rb/lib/selenium/webdriver/chrome/bridge.rb index 53ecea7215fa0..5e8642166ca6e 100644 --- a/rb/lib/selenium/webdriver/chrome/bridge.rb +++ b/rb/lib/selenium/webdriver/chrome/bridge.rb @@ -24,8 +24,13 @@ module Chrome class Bridge < Remote::Bridge def initialize(opts = {}) port = opts.delete(:port) || Service::DEFAULT_PORT + service_args = opts.delete(:service_args) || {} + if opts[:service_log_path] + service_args.merge!(service_log_path: opts.delete(:service_log_path)) + end + unless opts.key?(:url) - @service = Service.new(Chrome.driver_path, port, *extract_service_args(opts)) + @service = Service.new(Chrome.driver_path, port, *extract_service_args(service_args)) @service.start opts[:url] = @service.uri end @@ -83,10 +88,15 @@ def create_capabilities(opts) caps end - def extract_service_args(opts) - args = [] - args << "--log-path=#{opts.delete(:service_log_path)}" if opts.key?(:service_log_path) - args + def extract_service_args(args) + service_args = [] + service_args << "--log-path=#{args.delete(:service_log_path)}" if args.key?(:service_log_path) + service_args << "--url-base=#{args.delete(:url_base)}" if args.key?(:url_base) + service_args << "--port-server=#{args.delete(:port_server)}" if args.key?(:port_server) + service_args << "--whitelisted-ips=#{args.delete(:whitelisted_ips)}" if args.key?(:whitelisted_ips) + service_args << "--verbose=#{args.delete(:verbose)}" if args.key?(:whitelisted_ips) + service_args << "--silent=#{args.delete(:silent)}" if args.key?(:whitelisted_ips) + service_args end end # Bridge end # Chrome diff --git a/rb/lib/selenium/webdriver/edge/bridge.rb b/rb/lib/selenium/webdriver/edge/bridge.rb index 6bb243c0a7cc0..6b44af572705a 100644 --- a/rb/lib/selenium/webdriver/edge/bridge.rb +++ b/rb/lib/selenium/webdriver/edge/bridge.rb @@ -27,8 +27,9 @@ module Edge class Bridge < Remote::W3CBridge def initialize(opts = {}) port = opts.delete(:port) || Service::DEFAULT_PORT + service_args = opts.delete(:service_args) || {} unless opts.key?(:url) - @service = Service.new(Edge.driver_path, port) + @service = Service.new(Edge.driver_path, port, *extract_service_args(service_args)) @service.host = 'localhost' if @service.host == '127.0.0.1' @service.start opts[:url] = @service.uri @@ -60,6 +61,15 @@ def quit @service.stop if @service end + private + + def extract_service_args(args = {}) + service_args = [] + service_args << "–host=#{args[:host]}" if args.key? :host + service_args << "–package=#{args[:package]}" if args.key? :package + service_args << "-verbose" if args[:verbose] == true + service_args + end end # Bridge end # Edge end # WebDriver diff --git a/rb/lib/selenium/webdriver/firefox/w3c_bridge.rb b/rb/lib/selenium/webdriver/firefox/w3c_bridge.rb index 50200c6997bc0..f37d974ca75c7 100644 --- a/rb/lib/selenium/webdriver/firefox/w3c_bridge.rb +++ b/rb/lib/selenium/webdriver/firefox/w3c_bridge.rb @@ -25,8 +25,9 @@ class W3CBridge < Remote::W3CBridge def initialize(opts = {}) port = opts.delete(:port) || Service::DEFAULT_PORT opts[:desired_capabilities] = create_capabilities(opts) + service_args = opts.delete(:service_args) || {} - @service = Service.new(Firefox.driver_path, port) + @service = Service.new(Firefox.driver_path, port, *extract_service_args(service_args)) @service.start opts[:url] = @service.uri @@ -61,6 +62,17 @@ def create_capabilities(opts) Binary.path = caps[:firefox_options][:binary] if caps[:firefox_options].key?(:binary) caps end + + def extract_service_args(args = {}) + service_args = [] + service_args << "--binary=#{args[:binary]}" if args.key?(:binary) + service_args << "–-log=#{args[:log]}" if args.key?(:log) + service_args << "–-marionette-port=#{args[:marionette_port]}" if args.key?(:marionette_port) + service_args << "–-host=#{args[:host]}" if args.key?(:host) + service_args << "–-port=#{args[:port]}" if args.key?(:port) + service_args + end + end # W3CBridge end # Firefox end # WebDriver diff --git a/rb/lib/selenium/webdriver/ie/bridge.rb b/rb/lib/selenium/webdriver/ie/bridge.rb index 8984981636cf4..9be5b951a0011 100644 --- a/rb/lib/selenium/webdriver/ie/bridge.rb +++ b/rb/lib/selenium/webdriver/ie/bridge.rb @@ -27,8 +27,9 @@ module IE class Bridge < Remote::Bridge def initialize(opts = {}) port = opts.delete(:port) || Service::DEFAULT_PORT - - @service = Service.new(IE.driver_path, port, *extract_service_args(opts)) + service_args = opts.delete(:service_args) || {} + service_args = match_legacy(opts, service_args) + @service = Service.new(IE.driver_path, port, *extract_service_args(service_args)) @service.start opts[:url] = @service.uri @@ -55,13 +56,20 @@ def quit private - def extract_service_args(opts) - args = [] - args << "--log-level=#{opts.delete(:log_level).to_s.upcase}" if opts[:log_level] - args << "--log-file=#{opts.delete(:log_file)}" if opts[:log_file] - args << "--implementation=#{opts.delete(:implementation).to_s.upcase}" if opts[:implementation] + def match_legacy(opts, args) + args[:log_level] = opts.delete(:log_level) if opts.key?(:log_level) + args[:log_file] = opts.delete(:log_file) if opts.key?(:log_file) + args[:implementation] = opts.delete(:implementation) if opts.key?(:implementation) args end + + def extract_service_args(args) + service_args = [] + service_args << "--log-level=#{args.delete(:log_level).to_s.upcase}" if args.key?(:log_level) + service_args << "--log-file=#{args.delete(:log_file)}" if args.key?(:log_file) + service_args << "--implementation=#{args.delete(:implementation).to_s.upcase}" if args.key?(:implementation) + service_args + end end # Bridge end # IE end # WebDriver diff --git a/rb/lib/selenium/webdriver/safari/apple_bridge.rb b/rb/lib/selenium/webdriver/safari/apple_bridge.rb index 76d32f5b1a196..66ff201921dec 100644 --- a/rb/lib/selenium/webdriver/safari/apple_bridge.rb +++ b/rb/lib/selenium/webdriver/safari/apple_bridge.rb @@ -23,10 +23,11 @@ module Safari # @api private class AppleBridge < Remote::Bridge def initialize(opts = {}) - port = opts.delete(:port) || Service::DEFAULT_PORT opts[:desired_capabilities] ||= Remote::Capabilities.safari + port = opts.delete(:port) || Service::DEFAULT_PORT + service_args = opts.delete(:service_args) || {} - @service = Service.new(Safari.driver_path, port, *extract_service_args(opts)) + @service = Service.new(Safari.driver_path, port, *extract_service_args(service_args)) @service.start opts[:url] = @service.uri @@ -38,6 +39,12 @@ def quit ensure @service.stop if @service end + + private + + def extract_service_args(args = {}) + ["–host=#{args[:port]}"] if args.key? :port + end end # AppleBridge end # Safari end # WebDriver diff --git a/rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb b/rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb index c0a3566ae61fa..21a2c8173b00b 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb +++ b/rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb @@ -63,25 +63,52 @@ def restart_remote_server end end - it 'takes a binary path as an argument' do - pending "Set ENV['ALT_FIREFOX_BINARY'] to test this" unless ENV['ALT_FIREFOX_BINARY'] - begin - driver1 = Selenium::WebDriver.for GlobalTestEnv.driver, @opt.dup + # Remote needs to implement firefox options + not_compliant_on driver: :remote do + it 'takes a binary path as an argument' do + pending "Set ENV['ALT_FIREFOX_BINARY'] to test this" unless ENV['ALT_FIREFOX_BINARY'] + begin + driver1 = Selenium::WebDriver.for GlobalTestEnv.driver, @opt.dup - default_version = driver1.capabilities.version - expect { driver1.capabilities.browser_version }.to_not raise_exception NoMethodError - driver1.quit + default_version = driver1.capabilities.version + expect { driver1.capabilities.browser_version }.to_not raise_exception NoMethodError + driver1.quit - caps = Remote::Capabilities.firefox(firefox_options: {binary: ENV['ALT_FIREFOX_BINARY']}) - @opt[:desired_capabilities] = caps - driver2 = Selenium::WebDriver.for GlobalTestEnv.driver, @opt + caps = Remote::Capabilities.firefox(firefox_options: {binary: ENV['ALT_FIREFOX_BINARY']}) + @opt[:desired_capabilities] = caps + driver2 = Selenium::WebDriver.for GlobalTestEnv.driver, @opt + + expect(driver2.capabilities.version).to_not eql(default_version) + expect { driver2.capabilities.browser_version }.to_not raise_exception NoMethodError + driver2.quit + ensure + Firefox::Binary.reset_path! + end + end + + it 'gives precedence to firefox options versus argument switch' do + pending "Set ENV['ALT_FIREFOX_BINARY'] to test this" unless ENV['ALT_FIREFOX_BINARY'] + begin + driver1 = Selenium::WebDriver.for GlobalTestEnv.driver, @opt.dup + + default_path = Firefox::Binary.path + default_version = driver1.capabilities.version + driver1.quit + + caps = Remote::Capabilities.firefox(firefox_options: {binary: ENV['ALT_FIREFOX_BINARY']}, + service_args: {binary: default_path}) + @opt[:desired_capabilities] = caps + driver2 = Selenium::WebDriver.for GlobalTestEnv.driver, @opt + + expect(driver2.capabilities.version).to_not eql(default_version) + expect { driver2.capabilities.browser_version }.to_not raise_exception NoMethodError + driver2.quit + ensure + Firefox::Binary.reset_path! + end - expect(driver2.capabilities.version).to_not eql(default_version) - expect { driver2.capabilities.browser_version }.to_not raise_exception NoMethodError - driver2.quit - ensure - Firefox::Binary.reset_path! end + end # https://github.com/mozilla/geckodriver/issues/58