Skip to content

Commit c507f16

Browse files
committed
rb - update w3c error handling
1 parent 3ea3cd7 commit c507f16

File tree

5 files changed

+23
-29
lines changed

5 files changed

+23
-29
lines changed

rb/lib/selenium/webdriver/common/w3c_error.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class InvalidSessionIdError < WebDriverError; end
8080
# An error occurred while executing JavaScript supplied by the user.
8181
#
8282

83-
class JavascriptErrorError < WebDriverError; end
83+
class JavascriptError < WebDriverError; end
8484

8585
#
8686
# The target for mouse interaction is not in the browser’s viewport and
@@ -164,7 +164,7 @@ class UnexpectedAlertOpenError < WebDriverError; end
164164
# the command.
165165
#
166166

167-
class UnknownErrorError < WebDriverError; end
167+
class UnknownError < WebDriverError; end
168168

169169
#
170170
# The requested command matched a known URL but did not match a
@@ -179,6 +179,15 @@ class UnknownMethodError < WebDriverError; end
179179

180180
class UnsupportedOperationError < WebDriverError; end
181181

182+
# aliased for backwards compatibility
183+
NoAlertPresentError = NoSuchAlertError
184+
ScriptTimeOutError = ScriptTimeoutError
185+
ObsoleteElementError = StaleElementReferenceError
186+
UnhandledError = UnknownError
187+
UnexpectedJavascriptError = JavascriptError
188+
NoAlertOpenError = NoAlertPresentError
189+
ElementNotDisplayedError = ElementNotVisibleError
190+
182191

183192
end # Error
184193
end # WebDriver

rb/lib/selenium/webdriver/firefox/service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def start_process
9898
server_command = [@executable_path, "--binary=#{Firefox::Binary.path}", "--webdriver-port=#{@port}", *@extra_args]
9999
@process = ChildProcess.build(*server_command)
100100

101-
@process.io.inherit! if $DEBUG == true
101+
@process.io.inherit!
102102
@process.start
103103
end
104104

rb/spec/integration/selenium/webdriver/driver_spec.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,15 +280,10 @@
280280
# Edge BUG - https://connect.microsoft.com/IE/feedback/details/1849991/
281281
not_compliant_on :browser => :edge do
282282
it "times out if the callback is not invoked" do
283-
expected_error = Selenium::WebDriver::Error::ScriptTimeoutError
284-
not_compliant_on :w3c => true do
285-
expected_error = Selenium::WebDriver::Error::ScriptTimeOutError
286-
end
287-
288283
expect {
289284
# Script is expected to be async and explicitly callback, so this should timeout.
290285
driver.execute_async_script "return 1 + 2;"
291-
}.to raise_error(expected_error)
286+
}.to raise_error(Selenium::WebDriver::Error::ScriptTimeoutError)
292287
end
293288
end
294289
end

rb/spec/integration/selenium/webdriver/target_locator_spec.rb

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -274,30 +274,18 @@
274274
end
275275

276276
it "raises when calling #text on a closed alert" do
277-
expected_alert = Selenium::WebDriver::Error::NoSuchAlertError
278-
279-
not_compliant_on :w3c => true do
280-
expected_alert = Selenium::WebDriver::Error::NoAlertPresentError
281-
end
282-
283277
driver.navigate.to url_for("alerts.html")
284278
driver.find_element(:id => "alert").click
285279

286280
alert = wait_for_alert
287281
alert.accept
288282

289-
expect { alert.text }.to raise_error(expected_alert)
283+
expect { alert.text }.to raise_error(Selenium::WebDriver::Error::NoSuchAlertError)
290284
end
291285

292286
not_compliant_on :browser => :ie do
293287
it "raises NoAlertOpenError if no alert is present" do
294-
expected_alert = Selenium::WebDriver::Error::NoSuchAlertError
295-
not_compliant_on :w3c => true do
296-
expected_alert = Selenium::WebDriver::Error::NoAlertPresentError
297-
end
298-
299-
expect { driver.switch_to.alert }.to raise_error(
300-
expected_alert, /alert|modal/i)
288+
expect { driver.switch_to.alert }.to raise_error(Selenium::WebDriver::Error::NoSuchAlertError, /alert|modal/i)
301289
end
302290
end
303291

rb/spec/integration/selenium/webdriver/timeout_spec.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,16 @@
6363
expect(driver.find_elements(:class_name => "redbox")).to be_empty
6464
end
6565

66-
it "should return after first attempt to find many after disabling implicit waits" do
67-
add = driver.find_element(:id => "adder")
66+
not_compliant_on(:w3c => true, :platform => :windows) do
67+
it "should return after first attempt to find many after disabling implicit waits" do
68+
add = driver.find_element(:id => "adder")
6869

69-
driver.manage.timeouts.implicit_wait = 3
70-
driver.manage.timeouts.implicit_wait = 0
71-
add.click
70+
driver.manage.timeouts.implicit_wait = 3
71+
driver.manage.timeouts.implicit_wait = 0
72+
add.click
7273

73-
expect(driver.find_elements(:class_name => "redbox")).to be_empty
74+
expect(driver.find_elements(:class_name => "redbox")).to be_empty
75+
end
7476
end
7577
end
7678

0 commit comments

Comments
 (0)