Skip to content

Commit

Permalink
rb - updates for windows compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
titusfortner committed Jun 17, 2016
1 parent aee3d87 commit 7ed8fcf
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 19 deletions.
1 change: 1 addition & 0 deletions rb/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Style/FileName:
# These need to be fixed
Style/MutableConstant:
Exclude:
- 'lib/selenium/webdriver/common/socket_poller.rb'
- 'lib/selenium/webdriver/remote/bridge.rb'
- 'lib/selenium/webdriver/remote/w3c_bridge.rb'

Expand Down
19 changes: 15 additions & 4 deletions rb/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ ruby_test(name = "remote-chrome",
"spec/integration/selenium/webdriver/remote/**/*_spec.rb"
],
include = ["rb/spec/integration", "build/rb/lib"],
deps = [":remote"]
deps = [
":remote",
":chrome"]
)

ruby_test(name = "remote-firefox",
Expand All @@ -206,7 +208,10 @@ ruby_test(name = "remote-phantomjs",
"spec/integration/selenium/webdriver/remote/**/*_spec.rb"
],
include = ["rb/spec/integration", "build/rb/lib"],
deps = [":remote"]
deps = [
":remote",
":phantomjs"
]
)

ruby_test(name = "remote-safari",
Expand All @@ -229,7 +234,10 @@ ruby_test(name = "remote-ie",
"spec/integration/selenium/webdriver/remote/**/*_spec.rb"
],
include = ["rb/spec/integration", "build/rb/lib"],
deps = [":remote"]
deps = [
":remote",
":ie"
]
)

ruby_test(name = "remote-edge",
Expand All @@ -252,7 +260,10 @@ ruby_test(name = "remote-marionette",
"spec/integration/selenium/webdriver/remote/**/*_spec.rb"
],
include = ["rb/spec/integration", "build/rb/lib"],
deps = [":remote"]
deps = [
":remote",
":marionette"
]
)

ruby_library(name = "safari",
Expand Down
1 change: 1 addition & 0 deletions rb/lib/selenium/webdriver/common/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def exit_hook

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

binary_names.each do |binary_name|
paths.each do |path|
Expand Down
4 changes: 2 additions & 2 deletions rb/lib/selenium/webdriver/common/socket_poller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ def closed?

CONNECT_TIMEOUT = 5

NOT_CONNECTED_ERRORS = [Errno::ECONNREFUSED, Errno::ENOTCONN, SocketError].freeze
NOT_CONNECTED_ERRORS = [Errno::ECONNREFUSED, Errno::ENOTCONN, SocketError]
NOT_CONNECTED_ERRORS << Errno::EPERM if Platform.cygwin?

CONNECTED_ERRORS = [Errno::EISCONN].freeze
CONNECTED_ERRORS = [Errno::EISCONN]
CONNECTED_ERRORS << Errno::EINVAL if Platform.windows?

if Platform.jruby?
Expand Down
10 changes: 5 additions & 5 deletions rb/lib/selenium/webdriver/edge/legacy_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ module WebDriver
module Edge
module LegacySupport
# These are commands Edge is still using from JSON Wire Protocol
%i[execute_script, execute_async_script, submit_element, double_click,
mouse_down, mouse_up, mouse_move_to, click,
send_keys_to_active_element, window_handles, window_handle,
window_size, resize_window, window_position, reposition_window,
maximize_window, alert_text, accept_alert, dismiss_alert].each do |cmd|
%i[executeScript, executeAsyncScript, submitElement, doubleClick,
mouseDown, mouseUp, mouseMoveTo, click,
sendKeysToActiveElement, getWindowHandles, getCurrentWindowHandle,
getWindowSize, setWindowSize, getWindowPosition, setWindowPosition,
maximizeWindow, getAlertText, acceptAlert, dismissAlert].each do |cmd|
jwp = Remote::Bridge::COMMANDS[cmd]
Remote::W3CBridge.command(cmd, jwp.first, jwp.last)
end
Expand Down
7 changes: 3 additions & 4 deletions rb/lib/selenium/webdriver/remote/w3c_bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def browser
end

def edge_check(opts)
return unless opts[:browser_name] && opts[:browser_name] == 'MicrosoftEdge'
caps = opts[:desired_capabilities]
return unless caps && caps[:browser_name] && caps[:browser_name] == 'MicrosoftEdge'
require_relative '../edge/legacy_support'
extend Edge::LegacySupport
end
Expand Down Expand Up @@ -193,9 +194,7 @@ def title
end

def page_source
execute_script('var source = document.documentElement.outerHTML;' \
'if (!source) { source = new XMLSerializer().serializeToString(document); }' \
'return source;')
execute :getPageSource
end

def switch_to_window(name)
Expand Down
3 changes: 2 additions & 1 deletion rb/lib/selenium/webdriver/remote/w3c_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ class W3CBridge
command :isElementEnabled, :get, 'session/:session_id/element/:id/enabled'

#
# script execution
# document handling
#

command :getPageSource, :get, '/session/:session_id/source'
command :executeScript, :post, 'session/:session_id/execute/sync'
command :executeAsyncScript, :post, 'session/:session_id/execute/async'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,12 @@ def root
private

def create_driver
method = "create_#{driver}_driver"
instance = defined?(method) ? send(method) : WebDriver::Driver.for(driver)

method = "create_#{driver}_driver".to_sym
instance = if private_methods.include?(method)
send method
else
WebDriver::Driver.for(driver)
end
@create_driver_error_count -= 1 unless @create_driver_error_count == 0
instance
rescue => ex
Expand Down

0 comments on commit 7ed8fcf

Please sign in to comment.