Skip to content

Commit

Permalink
[rb] remove deprecations for setting driver path by module method
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Feb 24, 2017
1 parent 4319d0a commit 07178f1
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 90 deletions.
14 changes: 1 addition & 13 deletions rb/lib/selenium/webdriver/chrome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,11 @@ module Selenium
module WebDriver
module Chrome
def self.driver_path=(path)
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
[DEPRECATION] `driver_path=` is deprecated. Pass the driver path as an option instead.
e.g. Selenium::WebDriver.for :chrome, driver_path: '/path'
DEPRECATE

Platform.assert_executable path
@driver_path = path
end

def self.driver_path(warning = true)
if warning
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
[DEPRECATION] `driver_path` is deprecated. Pass the driver path as an option instead.
e.g. Selenium::WebDriver.for :chrome, driver_path: '/path'
DEPRECATE
end

def self.driver_path
@driver_path ||= nil
end

Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/chrome/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize(opts = {})
end

unless opts.key?(:url)
driver_path = opts.delete(:driver_path) || Chrome.driver_path(false)
driver_path = opts.delete(:driver_path) || Chrome.driver_path
@service = Service.new(driver_path, port, *extract_service_args(service_args))
@service.start
opts[:url] = @service.uri
Expand Down
12 changes: 0 additions & 12 deletions rb/lib/selenium/webdriver/edge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,11 @@ module Selenium
module WebDriver
module Edge
def self.driver_path=(path)
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
[DEPRECATION] `driver_path=` is deprecated. Pass the driver path as an option instead.
e.g. Selenium::WebDriver.for :edge, driver_path: '/path'
DEPRECATE

Platform.assert_executable path
@driver_path = path
end

def self.driver_path(warning = true)
if warning
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
[DEPRECATION] `driver_path` is deprecated. Pass the driver path as an option instead.
e.g. Selenium::WebDriver.for :edge, driver_path: '/path'
DEPRECATE
end

@driver_path ||= nil
end
end # Edge
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/edge/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initialize(opts = {})
service_args = opts.delete(:service_args) || {}

unless opts.key?(:url)
driver_path = opts.delete(:driver_path) || Edge.driver_path(false)
driver_path = opts.delete(:driver_path) || Edge.driver_path
@service = Service.new(driver_path, port, *extract_service_args(service_args))
@service.host = 'localhost' if @service.host == '127.0.0.1'
@service.start
Expand Down
14 changes: 1 addition & 13 deletions rb/lib/selenium/webdriver/firefox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,11 @@ module Firefox
DEFAULT_LOAD_NO_FOCUS_LIB = false

def self.driver_path=(path)
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
[DEPRECATION] `driver_path=` is deprecated. Pass the driver path as an option instead.
e.g. Selenium::WebDriver.for :firefox, driver_path: '/path'
DEPRECATE

Platform.assert_executable path
@driver_path = path
end

def self.driver_path(warning = true)
if warning
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
[DEPRECATION] `driver_path` is deprecated. Pass the driver path as an option instead.
e.g. Selenium::WebDriver.for :firefox, driver_path: '/path'
DEPRECATE
end

def self.driver_path
@driver_path ||= nil
end

Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/firefox/w3c_bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def initialize(opts = {})
opts[:desired_capabilities] = create_capabilities(opts)
service_args = opts.delete(:service_args) || {}

driver_path = opts.delete(:driver_path) || Firefox.driver_path(false)
driver_path = opts.delete(:driver_path) || Firefox.driver_path
@service = Service.new(driver_path, port, *extract_service_args(service_args))
@service.start
opts[:url] = @service.uri
Expand Down
14 changes: 1 addition & 13 deletions rb/lib/selenium/webdriver/ie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,11 @@ module Selenium
module WebDriver
module IE
def self.driver_path=(path)
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
[DEPRECATION] `driver_path=` is deprecated. Pass the driver path as an option instead.
e.g. Selenium::WebDriver.for :ie, driver_path: '/path'
DEPRECATE

Platform.assert_executable path
@driver_path = path
end

def self.driver_path(warning = true)
if warning
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
[DEPRECATION] `driver_path` is deprecated. Pass the driver path as an option instead.
e.g. Selenium::WebDriver.for :ie, driver_path: '/path'
DEPRECATE
end

def self.driver_path
@driver_path ||= nil
end
end # IE
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/ie/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def initialize(opts = {})
port = opts.delete(:port) || Service::DEFAULT_PORT
service_args = opts.delete(:service_args) || {}
service_args = match_legacy(opts, service_args)
driver_path = opts.delete(:driver_path) || IE.driver_path(false)
driver_path = opts.delete(:driver_path) || IE.driver_path

@service = Service.new(driver_path, port, *extract_service_args(service_args))
@service.start
Expand Down
26 changes: 9 additions & 17 deletions rb/lib/selenium/webdriver/phantomjs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,17 @@
module Selenium
module WebDriver
module PhantomJS
def self.path=(path)
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
[DEPRECATION] `path=` is deprecated. Pass the driver path as an option instead.
e.g. Selenium::WebDriver.for :phantomjs, driver_path: '/path'
DEPRECATE

Platform.assert_executable path
@path = path
end

def self.path(warning = true)
if warning
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
[DEPRECATION] `path` is deprecated. Pass the driver path as an option instead.
e.g. Selenium::WebDriver.for :phantomjs, driver_path: '/path'
DEPRECATE
class << self
def path=(path)
Platform.assert_executable path
@path = path
end
alias_method :driver_path=, :path=

@path ||= nil
def path
@path ||= nil
end
alias_method :driver_path, :path
end
end # PhantomJS
end # WebDriver
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/phantomjs/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def initialize(opts = {})
opts[:desired_capabilities] ||= Remote::Capabilities.phantomjs

unless opts.key?(:url)
driver_path = opts.delete(:driver_path) || PhantomJS.path(false)
driver_path = opts.delete(:driver_path) || PhantomJS.path
args = opts.delete(:args) || opts[:desired_capabilities]['phantomjs.cli.args']
@service = Service.new(driver_path, port, *args)
@service.start
Expand Down
22 changes: 9 additions & 13 deletions rb/lib/selenium/webdriver/safari.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ module Selenium
module WebDriver
module Safari
class << self
def technology_preview
"/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver"
end

def technology_preview!
self.driver_path = technology_preview
end

def path=(path)
Platform.assert_executable(path)
@path = path
Expand All @@ -37,23 +45,11 @@ def path
end

def driver_path=(path)
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
[DEPRECATION] `driver_path=` is deprecated. Pass the driver path as an option instead.
e.g. Selenium::WebDriver.for :safari, driver_path: '/path'
DEPRECATE

Platform.assert_executable path
@driver_path = path
end

def driver_path(warning = true)
if warning
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
[DEPRECATION] `driver_path` is deprecated. Pass the driver path as an option instead.
e.g. Selenium::WebDriver.for :safari, driver_path: '/path'
DEPRECATE
end

def driver_path
@driver_path ||= nil
end
end
Expand Down
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/safari/bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def initialize(opts = {})
port = opts.delete(:port) || Service::DEFAULT_PORT
service_args = opts.delete(:service_args) || {}

driver_path = opts.delete(:driver_path) || Safari.driver_path(false)
driver_path = opts.delete(:driver_path) || Safari.driver_path
@service = Service.new(driver_path, port, *extract_service_args(service_args))
@service.start
opts[:url] = @service.uri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ def create_phantomjs_driver(opt = {})
end

def create_safari_preview_driver(opt = {})
tech_preview_driver = "/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver"
raise DriverInstantiationError, "Install Safari Technology Preview on MacOS Sierra" unless File.exist?(tech_preview_driver)
opt[:driver_path] ||= tech_preview_driver
Safari.technology_preview!
WebDriver::Driver.for :safari, opt
end

Expand Down

0 comments on commit 07178f1

Please sign in to comment.