Skip to content

Commit

Permalink
correctly checks the driver supports DevTools
Browse files Browse the repository at this point in the history
When using a driver like EventFiringWebDriver as a parameter for JavaScriptEngine and trying to use StartEventMonitoring the constructor will throw a NullReferenceException. This is caused by casting the driver to IDevTools using "as" which will return null if the casting failed, and incorrectly checking the field "session" instead of "devToolsDriver" for null value.

fixes SeleniumHQ#10776
  • Loading branch information
elgatov committed Jun 27, 2022
1 parent 78f2b1e commit 2dfd149
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/JavaScriptEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public JavaScriptEngine(IWebDriver driver)
this.session = new Lazy<DevToolsSession>(() =>
{
IDevTools devToolsDriver = driver as IDevTools;
if (session == null)
if (devToolsDriver == null)
{
throw new WebDriverException("Driver must implement IDevTools to use these features");
}
Expand Down

0 comments on commit 2dfd149

Please sign in to comment.