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

[bug] Flaky Selenium Test: test_unsaved_changes #902

Open
nemesifier opened this issue Aug 1, 2024 · 2 comments
Open

[bug] Flaky Selenium Test: test_unsaved_changes #902

nemesifier opened this issue Aug 1, 2024 · 2 comments
Labels

Comments

@nemesifier
Copy link
Member

Flaky test:

======================================================================
FAIL: test_unsaved_changes (openwisp_controller.config.tests.test_selenium.TestDeviceAdmin) [Alert should be displayed after making changes]
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/openwisp-controller/openwisp-controller/openwisp_controller/config/tests/test_selenium.py", line 152, in test_unsaved_changes
    WebDriverWait(self.web_driver, 1).until(EC.alert_is_present())
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/selenium/webdriver/support/wait.py", line 105, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: 


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
    yield
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/case.py", line 582, in subTest
    yield
  File "/home/runner/work/openwisp-controller/openwisp-controller/openwisp_controller/config/tests/test_selenium.py", line 154, in test_unsaved_changes
    self.fail('Timed out wating for unsaved changes alert')
  File "/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/unittest/case.py", line 753, in fail
    raise self.failureException(msg)
AssertionError: Timed out wating for unsaved changes alert
@nemesifier
Copy link
Member Author

nemesifier commented Aug 2, 2024

This problem is caused by this change in Chromium, which was released in v126:

Ignore beforeunload dialogs

According to WebDriver standard the alerts arising on beforeunload event
must never be shown in Classic session. This commit implements
autoacceptance of any beforeunload alerts.

Ref: https://chromium.googlesource.com/chromium/src/+/5b3168e8f8c4487320c654dd761622b89d548514.

@nemesifier
Copy link
Member Author

It seems that we may have to switch using bidirectional sessions with the web driver, but it's not clear to me right now how to do that. A temporary workaround could be to use a chromium web-driver version older than 126.

nemesifier added a commit that referenced this issue Aug 3, 2024
Simulate gestures but is not enough.
Ref: https://chromium.googlesource.com/chromium/src/+/5b3168e8f8c4487320c654dd761622b89d548514.
Use chromium 125 for testing.
Added pip dependency caching.
I had to set CI to run on ubuntu-22.04, on ubuntu-24.04 the workaround did not work.

Related to #902
@nemesifier nemesifier moved this to To do (general) in OpenWISP Contributor's Board Aug 21, 2024
praptisharma28 pushed a commit that referenced this issue Sep 9, 2024
Simulate gestures but is not enough.
Ref: https://chromium.googlesource.com/chromium/src/+/5b3168e8f8c4487320c654dd761622b89d548514.
Use chromium 125 for testing.
Added pip dependency caching.
I had to set CI to run on ubuntu-22.04, on ubuntu-24.04 the workaround did not work.

Related to #902
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: To do (general)
Development

Successfully merging a pull request may close this issue.

1 participant