python-needle / needle

Automated tests for your CSS.
https://needle.readthedocs.io/
Other
590 stars 50 forks source link

Use FirefoxWebElement when appropriate #70

Closed jmbowman closed 7 years ago

jmbowman commented 7 years ago

In selenium 3.0.0.b3, a FirefoxWebElement class was added. The driver keeps track of which class is the appropriate one to use for elements in its _web_element_cls attribute, and when serializing arguments to execute_script(), determines if an argument is an element (which has a custom serialized representation) by whether or not it inherits that class. Because NeedleWebElement doesn't inherit from FirefoxWebElement, this was causing selenium to instead try to encode the object as JSON (which threw an exception). None of needle's test cases ran afoul of this, but calls to get_attribute() in bok-choy's tests did.

I turned the custom web element functionality into a mixin, and defined one web element class inheriting it for Firefox and another for all other browsers (Firefox is the only browser supported by needle which currently has a custom web element class).

I think this is the last thing I have to fix for the bok-choy tests to pass, hopefully I don't find more when running some of the tests in other repos that use bok-choy...

jmbowman commented 7 years ago

Argh, it looks like nose defeated the browser initialization retry loop I added earlier by dynamically rewriting WebDriverException to come from a different module (nose.proxy.WebDriverException). I'll see if I can make it compensate for that.

jphalip commented 7 years ago

Awesome, thank you! This will be included in the next release, which I can create some time within the next couple of days.