Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correctly checks the driver supports DevTools #10819

Merged
merged 1 commit into from Jul 5, 2022

Conversation

elgatov
Copy link
Contributor

@elgatov elgatov commented Jun 27, 2022

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 #10776

Description

This commit will correctly check in the JavascriptEngine constructor that the driver passed as a parameter supports DevTools

Motivation and Context

Previously the JavascriptEngine constructor checked the field session was not null, instead of the field devToolsDriver which would cause a NullReferenceException when using an incompatible driver like the EventFiringWebDriver. Now it correctly check the field devToolsDriver and, if the casting of the driver to IDevTools returns null, the JavascriptEngine constructor will correctly throw a WebDriverException with the message "Driver must implement IDevTools to use these features"

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@titusfortner titusfortner merged commit cd3af6e into SeleniumHQ:trunk Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants