Skip to content

Commit d9c9ea9

Browse files
committed
rb - add support for w3c commands
1 parent ef90939 commit d9c9ea9

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

rb/lib/selenium/webdriver/common/search_context.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def find_element(*args)
5959
end
6060

6161
bridge.find_element_by by, what.to_s, ref
62+
rescue Selenium::WebDriver::Error::TimeOutError
63+
# Implicit Wait times out in Edge
64+
raise Selenium::WebDriver::Error::NoSuchElementError
6265
end
6366

6467
#
@@ -79,6 +82,9 @@ def find_elements(*args)
7982
end
8083

8184
bridge.find_elements_by by, what.to_s, ref
85+
rescue Selenium::WebDriver::Error::TimeOutError
86+
# Implicit Wait times out in Edge
87+
[]
8288
end
8389

8490
private

rb/lib/selenium/webdriver/common/target_locator.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def window(id)
6363
nil
6464
end
6565

66+
unless @bridge.getWindowHandles.include? id
67+
raise Error::NoSuchWindowError, "The specified identifier '#{id}' is not found in the window handle list"
68+
end
69+
6670
@bridge.switchToWindow id
6771

6872
begin

rb/lib/selenium/webdriver/remote/bridge.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,23 @@ def getAlert
158158
end
159159

160160
def acceptAlert
161-
execute :acceptAlert
161+
command = capabilities.browser_name == 'MicrosoftEdge' ? :acceptAlertW3C : :acceptAlert
162+
execute command
162163
end
163164

164165
def dismissAlert
165-
execute :dismissAlert
166+
command = capabilities.browser_name == 'MicrosoftEdge' ? :dismissAlertW3C : :dismissAlert
167+
execute command
166168
end
167169

168170
def setAlertValue(keys)
169-
execute :setAlertValue, {}, :text => keys.to_s
171+
command = capabilities.browser_name == 'MicrosoftEdge' ? :setAlertValueW3C : :setAlertValue
172+
execute command, {}, :text => keys.to_s
170173
end
171174

172175
def getAlertText
173-
execute :getAlertText
176+
command = capabilities.browser_name == 'MicrosoftEdge' ? :getAlertTextW3C : :getAlertText
177+
execute command
174178
end
175179

176180
#
@@ -206,7 +210,11 @@ def setVisible(bool)
206210
end
207211

208212
def switchToWindow(name)
209-
execute :switchToWindow, {}, :name => name
213+
if capabilities.browser_name == 'MicrosoftEdge'
214+
execute :switchToWindow, {}, :handle => name
215+
else
216+
execute :switchToWindow, {}, :name => name
217+
end
210218
end
211219

212220
def switchToFrame(id)

rb/lib/selenium/webdriver/remote/commands.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ class Selenium::WebDriver::Remote::Bridge
7878
command :getAlertText, :get, "session/:session_id/alert_text"
7979
command :setAlertValue, :post, "session/:session_id/alert_text"
8080

81+
command :dismissAlertW3C, :post, "session/:session_id/alert/dismiss"
82+
command :acceptAlertW3C, :post, "session/:session_id/alert/accept"
83+
command :getAlertTextW3C, :get, "session/:session_id/alert/text"
84+
command :setAlertValueW3C, :post, "session/:session_id/alert/text"
85+
8186
#
8287
# target locator
8388
#

0 commit comments

Comments
 (0)