Fix access to specializations when Selenium::Driver is subclassed #2185
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This problem was introduced in this commit (i.e. since the v3.17.0 release) and is causing
NoMethodError
exceptions in all the JS-related feature specs in an app I'm working on.The specializations are stored in a class instance variable. However, they are accessed from the
#specialize_driver
method viaself.class
.Previously if this method was called within an instance of a subclass of
Selenium::Driver
, then it accessed the class instance variable associated with the subclass (which isnil
by default) and not the class instance variable associated with theSelenium::Driver
class as intended resulting in an exception like this:This commit adds a spec using a subclass of
Selenium::Driver
with Chrome to demonstrate the problem and fixes it by changing the#specialize_driver
method to access the specializations via the explicitly specified class name rather than viaself.class
.An alternative fix would be to use a class variable for specializations and do away with the class attribute reader altogether.