Skip to content

Commit 6b436ca

Browse files
committed
Updating unhandled JavaScript errors to throw WebDriverException in .NET
1 parent 7e15196 commit 6b436ca

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

dotnet/src/webdriver/Remote/RemoteWebDriver.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,9 @@ private static void UnpackAndThrowOnError(Response errorResponse)
14351435
case WebDriverResult.InvalidArgument:
14361436
throw new WebDriverException(errorMessage);
14371437

1438+
case WebDriverResult.UnexpectedJavaScriptError:
1439+
throw new WebDriverException(errorMessage);
1440+
14381441
default:
14391442
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "{0} ({1})", errorMessage, errorResponse.Status));
14401443
}

dotnet/test/common/CookieImplementationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ public void ShouldNotShowCookieAddedToDifferentDomain()
634634
driver.Url = macbethPage;
635635
IOptions options = driver.Manage();
636636
Cookie cookie = new Cookie("Bart", "Simpson", EnvironmentManager.Instance.UrlBuilder.HostName + ".com", EnvironmentManager.Instance.UrlBuilder.Path, null);
637-
Assert.Throws<WebDriverException>(() => options.Cookies.AddCookie(cookie));
637+
Assert.That(() => options.Cookies.AddCookie(cookie), Throws.InstanceOf<WebDriverException>());
638638
ReadOnlyCollection<Cookie> cookies = options.Cookies.AllCookies;
639639
Assert.IsFalse(cookies.Contains(cookie), "Invalid cookie was returned");
640640
}

dotnet/test/common/ExecutingAsyncJavascriptTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,14 @@ public void ShouldTimeoutIfScriptDoesNotInvokeCallbackWithLongTimeout()
166166
public void ShouldDetectPageLoadsWhileWaitingOnAnAsyncScriptAndReturnAnError()
167167
{
168168
driver.Url = ajaxyPage;
169-
Assert.Throws<InvalidOperationException>(() => executor.ExecuteAsyncScript("window.location = '" + dynamicPage + "';"));
169+
Assert.That(() => executor.ExecuteAsyncScript("window.location = '" + dynamicPage + "';"), Throws.InstanceOf<WebDriverException>());
170170
}
171171

172172
[Test]
173173
public void ShouldCatchErrorsWhenExecutingInitialScript()
174174
{
175175
driver.Url = ajaxyPage;
176-
Assert.Throws<InvalidOperationException>(() => executor.ExecuteAsyncScript("throw Error('you should catch this!');"));
176+
Assert.That(() => executor.ExecuteAsyncScript("throw Error('you should catch this!');"), Throws.InstanceOf<WebDriverException>());
177177
}
178178

179179
[Test]

dotnet/test/common/ExecutingJavascriptTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public void ShouldThrowAnExceptionWhenTheJavascriptIsBad()
219219
return;
220220

221221
driver.Url = xhtmlTestPage;
222-
Assert.Throws<WebDriverException>(() => ExecuteScript("return squiggle();"));
222+
Assert.That(() => ExecuteScript("return squiggle();"), Throws.InstanceOf<WebDriverException>());
223223
}
224224

225225
[Test]

0 commit comments

Comments
 (0)