mherrmann / helium

Lighter web automation with Python
MIT License
4.92k stars 374 forks source link

Update to support Selenium 4 + up to Python v3.11 #96

Closed nchantarotwong closed 1 year ago

nchantarotwong commented 1 year ago

-bump supported Python & selenium versions to work with newer python + selenium 4 -updated chromedriver to v107 and update geckodriver -removed Python3.5 (pretty old) -bump the module version

CLAassistant commented 1 year ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

:white_check_mark: nchantarotwong
:x: Nels Chantarotwong


Nels Chantarotwong seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

mherrmann commented 1 year ago

Thank you for the PR. However, it makes most of the tests fail. Please see the Contributing section in the README. When I execute python setup.py test, I get:

...

======================================================================
ERROR: test_text_in_nested_iframe_exists (tests.api.test_iframe.IframeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/michael/dev/helium/tests/api/test_iframe.py", line 10, in test_text_in_nested_iframe_exists
    self.assertTrue(Text("This text is inside a nested iframe.").exists())
  File "/home/michael/dev/helium/helium/__init__.py", line 518, in exists
    return self._impl.exists()
  File "/home/michael/dev/helium/helium/_impl/__init__.py", line 626, in exists
    next(self.find_all())
  File "/home/michael/dev/helium/helium/_impl/__init__.py", line 614, in find_all
    for occurrence in self.find_all_occurrences():
  File "/home/michael/dev/helium/helium/_impl/__init__.py", line 720, in find_all_occurrences
    for occurrence in self.find_all_in_curr_frame():
  File "/home/michael/dev/helium/helium/_impl/__init__.py", line 798, in find_all_in_curr_frame
    WebElementWrapper, self._driver.find_elements_by_xpath(x_path)
  File "/home/michael/dev/helium/helium/_impl/selenium_wrappers.py", line 46, in find_elements_by_xpath
    return self.target.find_elements_by_xpath(xpath) or []
AttributeError: 'WebDriver' object has no attribute 'find_elements_by_xpath'

----------------------------------------------------------------------
Ran 300 tests in 28.980s

FAILED (errors=211)
Test failed: <unittest.runner.TextTestResult run=300 errors=211 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=300 errors=211 failures=0>
nchantarotwong commented 1 year ago

These tests have to be re-written as that is the old syntax for find elements, which is no longer supported in Selenium 4.

It looks like this now: driver.find_elements(by=By.XPATH, value=findhow)

mherrmann commented 1 year ago

Yup, I agree.

nchantarotwong commented 1 year ago

I fixed the driver init calls, test element finds, etc. 4 corner tests are failing, not sure why, but everything else is passing.

FAIL: test_click_top_left (tests.api.test_point.PointTest.test_click_top_left)

Traceback (most recent call last): File "/Users/nelschantarotwong/PycharmProjects/sfdc-automation/module_installs/selenium-python-helium-3.1.1/tests/api/test_point.py", line 43, in test_click_top_left self.assert_result_is( File "/Users/nelschantarotwong/PycharmProjects/sfdc-automation/module_installs/selenium-python-helium-3.1.1/tests/api/test_point.py", line 107, in assert_result_is self.assert_around( File "/Users/nelschantarotwong/PycharmProjects/sfdc-automation/module_installs/selenium-python-helium-3.1.1/tests/api/test_point.py", line 38, in assert_around self.assertIn( AssertionError: 50 not found in [-1, 0, 1] : Offset (50, 15) is not in expected range (0+-1, 0+-1).

====================================================================== FAIL: test_doubleclick_top_left (tests.api.test_point.PointTest.test_doubleclick_top_left)

Traceback (most recent call last): File "/Users/nelschantarotwong/PycharmProjects/sfdc-automation/module_installs/selenium-python-helium-3.1.1/tests/api/test_point.py", line 84, in test_doubleclick_top_left self.assert_result_is( File "/Users/nelschantarotwong/PycharmProjects/sfdc-automation/module_installs/selenium-python-helium-3.1.1/tests/api/test_point.py", line 107, in assert_result_is self.assert_around( File "/Users/nelschantarotwong/PycharmProjects/sfdc-automation/module_installs/selenium-python-helium-3.1.1/tests/api/test_point.py", line 38, in assert_around self.assertIn( AssertionError: 50 not found in [-1, 0, 1] : Offset (50, 15) is not in expected range (0+-1, 0+-1).

====================================================================== FAIL: test_hover_top_left (tests.api.test_point.PointTest.test_hover_top_left)

Traceback (most recent call last): File "/Users/nelschantarotwong/PycharmProjects/sfdc-automation/module_installs/selenium-python-helium-3.1.1/tests/api/test_point.py", line 56, in test_hover_top_left self.assert_result_is( File "/Users/nelschantarotwong/PycharmProjects/sfdc-automation/module_installs/selenium-python-helium-3.1.1/tests/api/test_point.py", line 107, in assert_result_is self.assert_around( File "/Users/nelschantarotwong/PycharmProjects/sfdc-automation/module_installs/selenium-python-helium-3.1.1/tests/api/test_point.py", line 38, in assert_around self.assertIn( AssertionError: 50 not found in [-1, 0, 1] : Offset (50, 15) is not in expected range (0+-1, 0+-1).

====================================================================== FAIL: test_rightclick_top_left (tests.api.test_point.PointTest.test_rightclick_top_left)

Traceback (most recent call last): File "/Users/nelschantarotwong/PycharmProjects/sfdc-automation/module_installs/selenium-python-helium-3.1.1/tests/api/test_point.py", line 69, in test_rightclick_top_left self.assert_result_is( File "/Users/nelschantarotwong/PycharmProjects/sfdc-automation/module_installs/selenium-python-helium-3.1.1/tests/api/test_point.py", line 107, in assert_result_is self.assert_around( File "/Users/nelschantarotwong/PycharmProjects/sfdc-automation/module_installs/selenium-python-helium-3.1.1/tests/api/test_point.py", line 38, in assert_around self.assertIn( AssertionError: 50 not found in [-1, 0, 1] : Offset (50, 15) is not in expected range (0+-1, 0+-1).


Ran 306 tests in 120.101s

FAILED (failures=4, skipped=3) Test failed: error: Test failed:

mherrmann commented 1 year ago

ChatGPT has entered the chat. I've deleted the spam message and reported the account.

LeilaSchooley commented 1 year ago

ChatGPT has entered the chat. I've deleted the spam message and reported the account.

This is my legitimate account, i inputted his error and tried to help him debug it by copying the output.

If you don't want to maintain your repo, fine. Just don't make assumptions about those trying to help, especially reporting my developer account with all my work on it for posting one message.

mherrmann commented 1 year ago

I thought your account was a bot. Maybe next time you could prefix the comment with "I typed this into ChatGPT. Here's what it said". Then I'd have better reason to believe it was written by a human.

rsinsuranceagent commented 1 year ago

@nchantarotwong how are all your tests (minus the 4 corner tests) passing? I just cloned this branch, ran tests with python 3.7.16

python3 -m pip install -Ur requirements/test.txt
python3 setup.py test

and got

----------------------------------------------------------------------
Ran 59 tests in 48.434s

FAILED (failures=1, errors=33)
Test failed: <unittest.runner.TextTestResult run=59 errors=33 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=59 errors=33 failures=1>
rsinsuranceagent commented 1 year ago

@mherrmann @nchantarotwong who needs to sign the CLA? Would that be the only thing missing to merge this PR?

mherrmann commented 1 year ago

The tests need to pass for this PR to get merged; the CLA is secondary.