selenium-webdriver 2.53.4 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/CHANGES +24 -18
  2. data/README.md +2 -3
  3. data/lib/selenium/server.rb +64 -68
  4. data/lib/selenium/webdriver.rb +5 -9
  5. data/lib/selenium/webdriver/chrome.rb +18 -3
  6. data/lib/selenium/webdriver/chrome/bridge.rb +13 -16
  7. data/lib/selenium/webdriver/chrome/profile.rb +7 -9
  8. data/lib/selenium/webdriver/chrome/service.rb +8 -84
  9. data/lib/selenium/webdriver/common.rb +1 -2
  10. data/lib/selenium/webdriver/common/action_builder.rb +28 -38
  11. data/lib/selenium/webdriver/common/alert.rb +7 -10
  12. data/lib/selenium/webdriver/common/bridge_helper.rb +10 -15
  13. data/lib/selenium/webdriver/common/driver.rb +19 -28
  14. data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +0 -3
  15. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +4 -6
  16. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +4 -5
  17. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +0 -2
  18. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +0 -2
  19. data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +0 -2
  20. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +0 -3
  21. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +3 -6
  22. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +2 -5
  23. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +2 -5
  24. data/lib/selenium/webdriver/common/element.rb +27 -29
  25. data/lib/selenium/webdriver/common/error.rb +17 -20
  26. data/lib/selenium/webdriver/common/file_reaper.rb +3 -9
  27. data/lib/selenium/webdriver/common/html5/local_storage.rb +6 -8
  28. data/lib/selenium/webdriver/common/html5/session_storage.rb +6 -8
  29. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +6 -15
  30. data/lib/selenium/webdriver/common/keyboard.rb +7 -12
  31. data/lib/selenium/webdriver/common/keys.rb +67 -69
  32. data/lib/selenium/webdriver/common/log_entry.rb +3 -4
  33. data/lib/selenium/webdriver/common/logs.rb +2 -4
  34. data/lib/selenium/webdriver/common/mouse.rb +9 -12
  35. data/lib/selenium/webdriver/common/navigation.rb +2 -4
  36. data/lib/selenium/webdriver/common/options.rb +16 -19
  37. data/lib/selenium/webdriver/common/platform.rb +61 -90
  38. data/lib/selenium/webdriver/common/port_prober.rb +1 -2
  39. data/lib/selenium/webdriver/common/profile_helper.rb +5 -8
  40. data/lib/selenium/webdriver/common/proxy.rb +58 -70
  41. data/lib/selenium/webdriver/common/search_context.rb +15 -19
  42. data/lib/selenium/webdriver/common/service.rb +127 -0
  43. data/lib/selenium/webdriver/common/socket_lock.rb +5 -11
  44. data/lib/selenium/webdriver/common/socket_poller.rb +4 -9
  45. data/lib/selenium/webdriver/common/target_locator.rb +11 -13
  46. data/lib/selenium/webdriver/common/timeouts.rb +4 -6
  47. data/lib/selenium/webdriver/common/touch_action_builder.rb +2 -4
  48. data/lib/selenium/webdriver/common/touch_screen.rb +15 -18
  49. data/lib/selenium/webdriver/common/w3c_error.rb +3 -6
  50. data/lib/selenium/webdriver/common/wait.rb +6 -11
  51. data/lib/selenium/webdriver/common/window.rb +12 -15
  52. data/lib/selenium/webdriver/common/zipper.rb +6 -8
  53. data/lib/selenium/webdriver/edge.rb +18 -3
  54. data/lib/selenium/webdriver/edge/bridge.rb +11 -16
  55. data/lib/selenium/webdriver/edge/legacy_support.rb +38 -39
  56. data/lib/selenium/webdriver/edge/service.rb +8 -82
  57. data/lib/selenium/webdriver/firefox.rb +25 -6
  58. data/lib/selenium/webdriver/firefox/binary.rb +37 -53
  59. data/lib/selenium/webdriver/firefox/bridge.rb +3 -6
  60. data/lib/selenium/webdriver/firefox/extension.rb +4 -6
  61. data/lib/selenium/webdriver/firefox/extension/prefs.json +1 -10
  62. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  63. data/lib/selenium/webdriver/firefox/launcher.rb +8 -11
  64. data/lib/selenium/webdriver/firefox/profile.rb +40 -42
  65. data/lib/selenium/webdriver/firefox/profiles_ini.rb +8 -15
  66. data/lib/selenium/webdriver/firefox/service.rb +23 -79
  67. data/lib/selenium/webdriver/firefox/util.rb +0 -2
  68. data/lib/selenium/webdriver/firefox/w3c_bridge.rb +2 -4
  69. data/lib/selenium/webdriver/ie.rb +16 -7
  70. data/lib/selenium/webdriver/ie/bridge.rb +16 -23
  71. data/lib/selenium/webdriver/{iphone.rb → ie/service.rb} +26 -4
  72. data/lib/selenium/webdriver/phantomjs.rb +8 -3
  73. data/lib/selenium/webdriver/phantomjs/bridge.rb +9 -11
  74. data/lib/selenium/webdriver/phantomjs/service.rb +17 -81
  75. data/lib/selenium/webdriver/remote.rb +0 -2
  76. data/lib/selenium/webdriver/remote/bridge.rb +193 -191
  77. data/lib/selenium/webdriver/remote/capabilities.rb +60 -90
  78. data/lib/selenium/webdriver/remote/commands.rb +197 -192
  79. data/lib/selenium/webdriver/remote/http/common.rb +15 -13
  80. data/lib/selenium/webdriver/remote/http/curb.rb +5 -9
  81. data/lib/selenium/webdriver/remote/http/default.rb +32 -37
  82. data/lib/selenium/webdriver/remote/http/persistent.rb +4 -6
  83. data/lib/selenium/webdriver/remote/response.rb +13 -21
  84. data/lib/selenium/webdriver/remote/server_error.rb +1 -3
  85. data/lib/selenium/webdriver/remote/w3c_bridge.rb +200 -195
  86. data/lib/selenium/webdriver/remote/w3c_capabilities.rb +38 -46
  87. data/lib/selenium/webdriver/remote/w3c_commands.rb +116 -113
  88. data/lib/selenium/webdriver/safari.rb +23 -7
  89. data/lib/selenium/{client/javascript_frameworks/jquery.rb → webdriver/safari/apple_bridge.rb} +28 -9
  90. data/lib/selenium/webdriver/safari/browser.rb +0 -2
  91. data/lib/selenium/webdriver/safari/{bridge.rb → legacy_bridge.rb} +12 -9
  92. data/lib/selenium/webdriver/safari/options.rb +3 -4
  93. data/lib/selenium/webdriver/safari/resources/client.js +56 -7255
  94. data/lib/selenium/webdriver/safari/server.rb +18 -24
  95. data/lib/selenium/{client/javascript_frameworks/prototype.rb → webdriver/safari/service.rb} +27 -9
  96. data/lib/selenium/webdriver/support.rb +1 -0
  97. data/lib/selenium/webdriver/support/abstract_event_listener.rb +17 -2
  98. data/lib/selenium/webdriver/support/block_event_listener.rb +1 -3
  99. data/lib/selenium/webdriver/support/color.rb +55 -38
  100. data/lib/selenium/webdriver/{android.rb → support/escaper.rb} +19 -4
  101. data/lib/selenium/webdriver/support/event_firing_bridge.rb +36 -38
  102. data/lib/selenium/webdriver/support/select.rb +33 -84
  103. data/selenium-webdriver.gemspec +23 -23
  104. metadata +19 -30
  105. data/lib/selenium-client.rb +0 -21
  106. data/lib/selenium/client.rb +0 -57
  107. data/lib/selenium/client/base.rb +0 -151
  108. data/lib/selenium/client/driver.rb +0 -29
  109. data/lib/selenium/client/errors.rb +0 -28
  110. data/lib/selenium/client/extensions.rb +0 -132
  111. data/lib/selenium/client/idiomatic.rb +0 -507
  112. data/lib/selenium/client/javascript_expression_builder.rb +0 -135
  113. data/lib/selenium/client/legacy_driver.rb +0 -1722
  114. data/lib/selenium/client/protocol.rb +0 -123
  115. data/lib/selenium/client/selenium_helper.rb +0 -49
  116. data/lib/selenium/rake/server_task.rb +0 -176
  117. data/lib/selenium/webdriver/android/bridge.rb +0 -68
  118. data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -28
  119. data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -61
  120. data/lib/selenium/webdriver/common/html5/location.rb +0 -19
  121. data/lib/selenium/webdriver/ie/server.rb +0 -133
  122. data/lib/selenium/webdriver/iphone/bridge.rb +0 -64
@@ -20,6 +20,7 @@
20
20
  require 'zip'
21
21
  require 'tempfile'
22
22
  require 'find'
23
+ require 'base64'
23
24
 
24
25
  module Selenium
25
26
  module WebDriver
@@ -28,13 +29,11 @@ module Selenium
28
29
  #
29
30
 
30
31
  module Zipper
31
-
32
- EXTENSIONS = %w[.zip .xpi]
32
+ EXTENSIONS = %w[.zip .xpi].freeze
33
33
 
34
34
  class << self
35
-
36
35
  def unzip(path)
37
- destination = Dir.mktmpdir("webdriver-unzip")
36
+ destination = Dir.mktmpdir('webdriver-unzip')
38
37
  FileReaper << destination
39
38
 
40
39
  Zip::File.open(path) do |zip|
@@ -59,7 +58,7 @@ module Selenium
59
58
  end
60
59
 
61
60
  zip.commit
62
- File.open(zip.name, "rb") { |io| Base64.strict_encode64 io.read }
61
+ File.open(zip.name, 'rb') { |io| Base64.strict_encode64 io.read }
63
62
  end
64
63
  end
65
64
 
@@ -68,7 +67,7 @@ module Selenium
68
67
  add_zip_entry zip, path, File.basename(path)
69
68
 
70
69
  zip.commit
71
- File.open(zip.name, "rb") { |io| Base64.strict_encode64 io.read }
70
+ File.open(zip.name, 'rb') { |io| Base64.strict_encode64 io.read }
72
71
  end
73
72
  end
74
73
 
@@ -78,7 +77,7 @@ module Selenium
78
77
  # can't use Tempfile here since it doesn't support File::BINARY mode on 1.8
79
78
  # can't use Dir.mktmpdir(&blk) because of http://jira.codehaus.org/browse/JRUBY-4082
80
79
  tmp_dir = Dir.mktmpdir
81
- zip_path = File.join(tmp_dir, "webdriver-zip")
80
+ zip_path = File.join(tmp_dir, 'webdriver-zip')
82
81
 
83
82
  begin
84
83
  Zip::File.open(zip_path, Zip::File::CREATE, &blk)
@@ -94,7 +93,6 @@ module Selenium
94
93
 
95
94
  zip.add entry, file
96
95
  end
97
-
98
96
  end
99
97
  end # Zipper
100
98
  end # WebDriver
@@ -24,10 +24,26 @@ require 'selenium/webdriver/edge/bridge'
24
24
 
25
25
  module Selenium
26
26
  module WebDriver
27
-
28
27
  module Edge
28
+ MISSING_TEXT = <<-ERROR.tr("\n", '').freeze
29
+ Unable to find MicrosoftWebDriver. Please download the server from
30
+ https://www.microsoft.com/en-us/download/details.aspx?id=48212 and place it
31
+ somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/MicrosoftWebDriver.
32
+ ERROR
33
+
29
34
  def self.driver_path=(path)
30
- Service.executable_path = path
35
+ Platform.assert_executable path
36
+ @driver_path = path
37
+ end
38
+
39
+ def self.driver_path
40
+ @driver_path ||= begin
41
+ path = Platform.find_binary('MicrosoftWebDriver')
42
+ raise Error::WebDriverError, MISSING_TEXT unless path
43
+ Platform.assert_executable path
44
+
45
+ path
46
+ end
31
47
  end
32
48
 
33
49
  def self.path=(path)
@@ -38,7 +54,6 @@ module Selenium
38
54
  def self.path
39
55
  @path ||= nil
40
56
  end
41
-
42
57
  end # Edge
43
58
  end # WebDriver
44
59
  end # Selenium
@@ -20,23 +20,19 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Edge
23
-
23
+ #
24
24
  # @api private
25
- class Bridge < Remote::W3CBridge
25
+ #
26
26
 
27
+ class Bridge < Remote::W3CBridge
27
28
  def initialize(opts = {})
28
-
29
29
  http_client = opts.delete(:http_client)
30
30
 
31
- if opts.has_key?(:url)
31
+ if opts.key?(:url)
32
32
  url = opts.delete(:url)
33
33
  else
34
- @service = Service.default_service(*extract_service_args(opts))
35
-
36
- if @service.instance_variable_get("@host") == "127.0.0.1"
37
- @service.instance_variable_set("@host", 'localhost')
38
- end
39
-
34
+ @service = Service.new(Edge.driver_path, Service::DEFAULT_PORT, *extract_service_args(opts))
35
+ @service.host = 'localhost' if @service.host == '127.0.0.1'
40
36
  @service.start
41
37
 
42
38
  url = @service.uri
@@ -45,11 +41,11 @@ module Selenium
45
41
  caps = create_capabilities(opts)
46
42
 
47
43
  remote_opts = {
48
- :url => url,
49
- :desired_capabilities => caps
44
+ url: url,
45
+ desired_capabilities: caps
50
46
  }
51
47
 
52
- remote_opts.merge!(:http_client => http_client) if http_client
48
+ remote_opts[:http_client] = http_client if http_client
53
49
  super(remote_opts)
54
50
  end
55
51
 
@@ -78,7 +74,7 @@ module Selenium
78
74
 
79
75
  def create_capabilities(opts)
80
76
  caps = opts.delete(:desired_capabilities) { Remote::W3CCapabilities.edge }
81
- page_load_strategy = opts.delete(:page_load_strategy) || "normal"
77
+ page_load_strategy = opts.delete(:page_load_strategy) || 'normal'
82
78
 
83
79
  unless opts.empty?
84
80
  raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
@@ -92,13 +88,12 @@ module Selenium
92
88
  def extract_service_args(opts)
93
89
  args = []
94
90
 
95
- if opts.has_key?(:service_log_path)
91
+ if opts.key?(:service_log_path)
96
92
  args << "--log-path=#{opts.delete(:service_log_path)}"
97
93
  end
98
94
 
99
95
  args
100
96
  end
101
-
102
97
  end # Bridge
103
98
  end # Edge
104
99
  end # WebDriver
@@ -20,97 +20,96 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Edge
23
-
24
23
  module LegacySupport
25
-
26
- # These are commands Edge is still using from JSON Wire Protocol
27
- [:executeScript, :executeAsyncScript, :submitElement, :doubleClick, :mouseDown, :mouseUp, :mouseMoveTo, :click,
28
- :sendKeysToActiveElement, :getWindowHandles, :getCurrentWindowHandle, :getWindowSize, :setWindowSize, :getWindowPosition,
29
- :setWindowPosition, :maximizeWindow, :getAlertText, :acceptAlert, :dismissAlert].each do |cmd|
24
+ # These are commands Edge is still using from JSON Wire Protocol
25
+ %i[executeScript executeAsyncScript submitElement doubleClick
26
+ mouseDown mouseUp mouseMoveTo click
27
+ sendKeysToActiveElement getWindowHandles getCurrentWindowHandle
28
+ getWindowSize setWindowSize getWindowPosition setWindowPosition
29
+ maximizeWindow getAlertText acceptAlert dismissAlert].each do |cmd|
30
30
  jwp = Remote::Bridge::COMMANDS[cmd]
31
31
  Remote::W3CBridge.command(cmd, jwp.first, jwp.last)
32
32
  end
33
33
 
34
- def executeScript(script, *args)
35
- result = execute :executeScript, {}, :script => script, :args => args
34
+ def execute_script(script, *args)
35
+ result = execute :executeScript, {}, {script: script, args: args}
36
36
  unwrap_script_result result
37
37
  end
38
38
 
39
- def executeAsyncScript(script, *args)
40
- result = execute :executeAsyncScript, {}, :script => script, :args => args
39
+ def execute_async_script(script, *args)
40
+ result = execute :executeAsyncScript, {}, {script: script, args: args}
41
41
  unwrap_script_result result
42
42
  end
43
43
 
44
- def submitElement(element)
45
- execute :submitElement, :id => element
44
+ def submit_element(element)
45
+ execute :submitElement, id: element
46
46
  end
47
47
 
48
- def doubleClick
48
+ def double_click
49
49
  execute :doubleClick
50
50
  end
51
51
 
52
52
  def click
53
- execute :click, {}, :button => 0
53
+ execute :click, {}, {button: 0}
54
54
  end
55
55
 
56
- def contextClick
57
- execute :click, {}, :button => 2
56
+ def context_click
57
+ execute :click, {}, {button: 2}
58
58
  end
59
59
 
60
- def mouseDown
60
+ def mouse_down
61
61
  execute :mouseDown
62
62
  end
63
63
 
64
- def mouseUp
64
+ def mouse_up
65
65
  execute :mouseUp
66
66
  end
67
67
 
68
- def mouseMoveTo(element, x = nil, y = nil)
69
- params = { :element => element }
68
+ def mouse_move_to(element, x = nil, y = nil)
69
+ params = {element: element}
70
70
 
71
71
  if x && y
72
- params.merge! :xoffset => x, :yoffset => y
72
+ params[:xoffset] = x
73
+ params[:yoffset] = y
73
74
  end
74
75
 
75
76
  execute :mouseMoveTo, {}, params
76
77
  end
77
78
 
78
- def sendKeysToActiveElement(key)
79
- execute :sendKeysToActiveElement, {}, :value => key
79
+ def send_keys_to_active_element(key)
80
+ execute :sendKeysToActiveElement, {}, {value: key}
80
81
  end
81
82
 
82
- def getCurrentWindowHandle
83
+ def window_handle
83
84
  execute :getCurrentWindowHandle
84
85
  end
85
86
 
86
- def getWindowSize(handle = :current)
87
- data = execute :getWindowSize, :window_handle => handle
87
+ def window_size(handle = :current)
88
+ data = execute :getWindowSize, window_handle: handle
88
89
 
89
90
  Dimension.new data['width'], data['height']
90
91
  end
91
92
 
92
- def setWindowSize(width, height, handle = :current)
93
- execute :setWindowSize, {:window_handle => handle},
94
- :width => width,
95
- :height => height
93
+ def resize_window(width, height, handle = :current)
94
+ execute :setWindowSize, {window_handle: handle},
95
+ {width: width,
96
+ height: height}
96
97
  end
97
98
 
98
- def getWindowPosition(handle = :current)
99
- data = execute :getWindowPosition, :window_handle => handle
99
+ def window_position(handle = :current)
100
+ data = execute :getWindowPosition, window_handle: handle
100
101
 
101
102
  Point.new data['x'], data['y']
102
103
  end
103
104
 
104
- def setWindowPosition(x, y, handle = :current)
105
- execute :setWindowPosition, {:window_handle => handle},
106
- :x => x, :y => y
105
+ def reposition_window(x, y, handle = :current)
106
+ execute :setWindowPosition, {window_handle: handle},
107
+ {x: x, y: y}
107
108
  end
108
109
 
109
- def maximizeWindow(handle = :current)
110
- execute :maximizeWindow, :window_handle => handle
110
+ def maximize_window(handle = :current)
111
+ execute :maximizeWindow, window_handle: handle
111
112
  end
112
-
113
-
114
113
  end # LegacySupport
115
114
  end # Edge
116
115
  end # WebDriver
@@ -20,104 +20,30 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Edge
23
-
24
23
  #
25
24
  # @api private
26
25
  #
27
26
 
28
- class Service
29
- START_TIMEOUT = 20
30
- SOCKET_LOCK_TIMEOUT = 45
31
- STOP_TIMEOUT = 5
32
- DEFAULT_PORT = 17556
33
- MISSING_TEXT = "Unable to find MicrosoftWebDriver. Please download the server from https://www.microsoft.com/en-us/download/details.aspx?id=48212. More info at https://github.com/SeleniumHQ/selenium/wiki/MicrosoftWebDriver."
34
-
35
- def self.executable_path
36
- @executable_path ||= (
37
- path = Platform.find_binary "MicrosoftWebDriver"
38
- path or raise Error::WebDriverError, MISSING_TEXT
39
- Platform.assert_executable path
40
-
41
- path
42
- )
43
- end
44
-
45
- def self.executable_path=(path)
46
- Platform.assert_executable path
47
- @executable_path = path
48
- end
49
-
50
- def self.default_service(*extra_args)
51
- new executable_path, DEFAULT_PORT, *extra_args
52
- end
53
-
54
- def initialize(executable_path, port, *extra_args)
55
- @executable_path = executable_path
56
- @host = Platform.localhost
57
- @port = Integer(port)
58
-
59
- raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1
60
-
61
- @extra_args = extra_args
62
- end
63
-
64
- def start
65
- Platform.exit_hook { stop } # make sure we don't leave the server running
27
+ class Service < WebDriver::Service
28
+ DEFAULT_PORT = 17556
66
29
 
67
- socket_lock.locked do
68
- find_free_port
69
- start_process
70
- connect_until_stable
71
- end
72
- end
73
-
74
- def stop
75
- return if @process.nil? || @process.exited?
76
-
77
- Net::HTTP.start(@host, @port) do |http|
78
- http.open_timeout = STOP_TIMEOUT / 2
79
- http.read_timeout = STOP_TIMEOUT / 2
80
-
81
- http.head("/shutdown")
82
- end
83
- ensure
84
- stop_process
85
- end
86
-
87
- def uri
88
- URI.parse "http://#{@host}:#{@port}"
89
- end
30
+ private
90
31
 
91
- def find_free_port
92
- @port = PortProber.above @port
32
+ def stop_server
33
+ connect_to_server { |http| http.head('/shutdown') }
93
34
  end
94
35
 
95
36
  def start_process
96
37
  server_command = [@executable_path, "--port=#{@port}", *@extra_args]
97
38
  @process = ChildProcess.build(*server_command)
98
39
 
99
- @process.io.inherit! if $DEBUG == true
40
+ @process.io.inherit! if $DEBUG
100
41
  @process.start
101
42
  end
102
43
 
103
- def stop_process
104
- @process.poll_for_exit STOP_TIMEOUT
105
- rescue ChildProcess::TimeoutError
106
- @process.stop STOP_TIMEOUT
44
+ def cannot_connect_error_text
45
+ "unable to connect to MicrosoftWebDriver #{@host}:#{@port}"
107
46
  end
108
-
109
- def connect_until_stable
110
- socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
111
-
112
- unless socket_poller.connected?
113
- raise Error::WebDriverError, "unable to connect to MicrosoftWebDriver #{@host}:#{@port}"
114
- end
115
- end
116
-
117
- def socket_lock
118
- @socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
119
- end
120
-
121
47
  end # Service
122
48
  end # Edge
123
49
  end # WebDriver
@@ -35,17 +35,36 @@ require 'selenium/webdriver/firefox/service'
35
35
  module Selenium
36
36
  module WebDriver
37
37
  module Firefox
38
-
39
- DEFAULT_PORT = 7055
40
- DEFAULT_ENABLE_NATIVE_EVENTS = Platform.os == :windows
41
- DEFAULT_SECURE_SSL = false
38
+ DEFAULT_PORT = 7055
39
+ DEFAULT_ENABLE_NATIVE_EVENTS = Platform.os == :windows
40
+ DEFAULT_SECURE_SSL = false
42
41
  DEFAULT_ASSUME_UNTRUSTED_ISSUER = true
43
- DEFAULT_LOAD_NO_FOCUS_LIB = false
42
+ DEFAULT_LOAD_NO_FOCUS_LIB = false
43
+
44
+ MISSING_TEXT = <<-ERROR.tr("\n", '').freeze
45
+ Unable to find Mozilla geckodriver. Please download the server from
46
+ https://github.com/mozilla/geckodriver/releases and place it
47
+ somewhere on your PATH. More info at https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver.
48
+ ERROR
49
+
50
+ def self.driver_path=(path)
51
+ Platform.assert_executable path
52
+ @driver_path = path
53
+ end
54
+
55
+ def self.driver_path
56
+ @driver_path ||= begin
57
+ path = Platform.find_binary('geckodriver*')
58
+ raise Error::WebDriverError, MISSING_TEXT unless path
59
+ Platform.assert_executable path
60
+
61
+ path
62
+ end
63
+ end
44
64
 
45
65
  def self.path=(path)
46
66
  Binary.path = path
47
67
  end
48
-
49
68
  end # Firefox
50
69
  end # WebDriver
51
70
  end # Selenium