Skip to content

Commit 7ed8fcf

Browse files
committed
rb - updates for windows compatibility
1 parent aee3d87 commit 7ed8fcf

File tree

8 files changed

+35
-19
lines changed

8 files changed

+35
-19
lines changed

rb/.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Style/FileName:
3737
# These need to be fixed
3838
Style/MutableConstant:
3939
Exclude:
40+
- 'lib/selenium/webdriver/common/socket_poller.rb'
4041
- 'lib/selenium/webdriver/remote/bridge.rb'
4142
- 'lib/selenium/webdriver/remote/w3c_bridge.rb'
4243

rb/build.desc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ ruby_test(name = "remote-chrome",
183183
"spec/integration/selenium/webdriver/remote/**/*_spec.rb"
184184
],
185185
include = ["rb/spec/integration", "build/rb/lib"],
186-
deps = [":remote"]
186+
deps = [
187+
":remote",
188+
":chrome"]
187189
)
188190

189191
ruby_test(name = "remote-firefox",
@@ -206,7 +208,10 @@ ruby_test(name = "remote-phantomjs",
206208
"spec/integration/selenium/webdriver/remote/**/*_spec.rb"
207209
],
208210
include = ["rb/spec/integration", "build/rb/lib"],
209-
deps = [":remote"]
211+
deps = [
212+
":remote",
213+
":phantomjs"
214+
]
210215
)
211216

212217
ruby_test(name = "remote-safari",
@@ -229,7 +234,10 @@ ruby_test(name = "remote-ie",
229234
"spec/integration/selenium/webdriver/remote/**/*_spec.rb"
230235
],
231236
include = ["rb/spec/integration", "build/rb/lib"],
232-
deps = [":remote"]
237+
deps = [
238+
":remote",
239+
":ie"
240+
]
233241
)
234242

235243
ruby_test(name = "remote-edge",
@@ -252,7 +260,10 @@ ruby_test(name = "remote-marionette",
252260
"spec/integration/selenium/webdriver/remote/**/*_spec.rb"
253261
],
254262
include = ["rb/spec/integration", "build/rb/lib"],
255-
deps = [":remote"]
263+
deps = [
264+
":remote",
265+
":marionette"
266+
]
256267
)
257268

258269
ruby_library(name = "safari",

rb/lib/selenium/webdriver/common/platform.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ def exit_hook
140140

141141
def find_binary(*binary_names)
142142
paths = ENV['PATH'].split(File::PATH_SEPARATOR)
143+
binary_names.map! { |n| "#{n}.exe" } if windows?
143144

144145
binary_names.each do |binary_name|
145146
paths.each do |path|

rb/lib/selenium/webdriver/common/socket_poller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ def closed?
5656

5757
CONNECT_TIMEOUT = 5
5858

59-
NOT_CONNECTED_ERRORS = [Errno::ECONNREFUSED, Errno::ENOTCONN, SocketError].freeze
59+
NOT_CONNECTED_ERRORS = [Errno::ECONNREFUSED, Errno::ENOTCONN, SocketError]
6060
NOT_CONNECTED_ERRORS << Errno::EPERM if Platform.cygwin?
6161

62-
CONNECTED_ERRORS = [Errno::EISCONN].freeze
62+
CONNECTED_ERRORS = [Errno::EISCONN]
6363
CONNECTED_ERRORS << Errno::EINVAL if Platform.windows?
6464

6565
if Platform.jruby?

rb/lib/selenium/webdriver/edge/legacy_support.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ module WebDriver
2222
module Edge
2323
module LegacySupport
2424
# These are commands Edge is still using from JSON Wire Protocol
25-
%i[execute_script, execute_async_script, submit_element, double_click,
26-
mouse_down, mouse_up, mouse_move_to, click,
27-
send_keys_to_active_element, window_handles, window_handle,
28-
window_size, resize_window, window_position, reposition_window,
29-
maximize_window, alert_text, accept_alert, dismiss_alert].each do |cmd|
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|
3030
jwp = Remote::Bridge::COMMANDS[cmd]
3131
Remote::W3CBridge.command(cmd, jwp.first, jwp.last)
3232
end

rb/lib/selenium/webdriver/remote/w3c_bridge.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def browser
9696
end
9797

9898
def edge_check(opts)
99-
return unless opts[:browser_name] && opts[:browser_name] == 'MicrosoftEdge'
99+
caps = opts[:desired_capabilities]
100+
return unless caps && caps[:browser_name] && caps[:browser_name] == 'MicrosoftEdge'
100101
require_relative '../edge/legacy_support'
101102
extend Edge::LegacySupport
102103
end
@@ -193,9 +194,7 @@ def title
193194
end
194195

195196
def page_source
196-
execute_script('var source = document.documentElement.outerHTML;' \
197-
'if (!source) { source = new XMLSerializer().serializeToString(document); }' \
198-
'return source;')
197+
execute :getPageSource
199198
end
200199

201200
def switch_to_window(name)

rb/lib/selenium/webdriver/remote/w3c_commands.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ class W3CBridge
7777
command :isElementEnabled, :get, 'session/:session_id/element/:id/enabled'
7878

7979
#
80-
# script execution
80+
# document handling
8181
#
8282

83+
command :getPageSource, :get, '/session/:session_id/source'
8384
command :executeScript, :post, 'session/:session_id/execute/sync'
8485
command :executeAsyncScript, :post, 'session/:session_id/execute/async'
8586

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,12 @@ def root
133133
private
134134

135135
def create_driver
136-
method = "create_#{driver}_driver"
137-
instance = defined?(method) ? send(method) : WebDriver::Driver.for(driver)
138-
136+
method = "create_#{driver}_driver".to_sym
137+
instance = if private_methods.include?(method)
138+
send method
139+
else
140+
WebDriver::Driver.for(driver)
141+
end
139142
@create_driver_error_count -= 1 unless @create_driver_error_count == 0
140143
instance
141144
rescue => ex

0 commit comments

Comments
 (0)