spyoungtech / behave-webdriver

Selenium webdriver step library for use with the behave BDD testing framework
MIT License
62 stars 21 forks source link

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases #88

Open haavardw opened 3 years ago

haavardw commented 3 years ago

Broken with selenium 4.0.0.

Reproduced with python 3.8.10 and 3.9.5

File "xxxxxxxxxxxx/venv/lib/python3.8/site-packages/behave_webdriver/conditions.py", line 48, in <module>
    class element_is_selected(NegationMixin, EC.element_located_to_be_selected):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Reproducable by running package tests:

git/behave-webdriver$ python setup.py test
running test
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
running egg_info
writing behave_webdriver.egg-info/PKG-INFO
writing dependency_links to behave_webdriver.egg-info/dependency_links.txt
writing requirements to behave_webdriver.egg-info/requires.txt
writing top-level names to behave_webdriver.egg-info/top_level.txt
reading manifest file 'behave_webdriver.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'behave_webdriver.egg-info/SOURCES.txt'
running build_ext
behave_webdriver (unittest.loader._FailedTest) ... ERROR

======================================================================
ERROR: behave_webdriver (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: behave_webdriver
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 470, in _find_test_path
    package = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/home/haavardw/git/behave-webdriver/behave_webdriver/__init__.py", line 15, in <module>
    from behave_webdriver.driver import (Chrome,
  File "/home/haavardw/git/behave-webdriver/behave_webdriver/driver.py", line 18, in <module>
    from behave_webdriver.conditions import (element_is_present,
  File "/home/haavardw/git/behave-webdriver/behave_webdriver/conditions.py", line 48, in <module>
    class element_is_selected(NegationMixin, EC.element_located_to_be_selected):
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

----------------------------------------------------------------------
Ran 1 test in 0.000s

FAILED (errors=1)
Test failed: <unittest.runner.TextTestResult run=1 errors=1 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=1 errors=1 failures=0>
haavardw commented 3 years ago

downgrading to selenium == 3.141.0 works around the issue

kevin-pelago commented 3 years ago

I'm also encountering this issue. downgrading selenium works for me too.

downgrading to selenium == 3.141.0 works around the issue

haavardw commented 3 years ago

selenium 4.0.0 was released yesterday and has changed EC.element_located_to_be_selected (and all the other classes in the same file) from being classes to functions, breaking the behave-webdriver pattern of inheritance and mixins.

spyoungtech commented 2 years ago

Thanks for tracking down the breaking change. I'll see if I can update the code to play nice in selenium 3.x and 4.x

For now, I've set selenium < 4 in the requirements (released oct 25 with v0.3.1).

shayneoneill commented 1 year ago

Whats the status on fixing this. Older versions of selenium seem to be incompatible with modern versions of URLLIB3 (urllib3 changed something to do with socket timeouts)

spyoungtech commented 1 year ago

Hi @shayneoneill I don't think I have a great answer for this right now. I'm not currently actively developing this project. I may find some time to take a closer look, but I can't make any promises right now.

I would be willing to review and accept pull requests for a fix, however, if someone else wants to take a stab at it.