-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
[tests] Fixed flaky test_topology_graph #430
base: master
Are you sure you want to change the base?
[tests] Fixed flaky test_topology_graph #430
Conversation
element = WebDriverWait(driver, 10).until( | ||
EC.presence_of_element_located((By.XPATH, path)) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's assume that the TimeoutError
is raised by this code. I would update the logic here
element = WebDriverWait(driver, 10).until( | |
EC.presence_of_element_located((By.XPATH, path)) | |
) | |
try: | |
element = WebDriverWait(driver, 10).until( | |
EC.presence_of_element_located((By.XPATH, path)) | |
) | |
except Exception: | |
import ipdb | |
ipdb.set_trace() |
The test execution will halt when the code in except block is executed. Now, inspect the webpage. open the JS console on browser (created by selenium) and look for any errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the development chat by @youhaveme9
Running the test manually always passes
But running the test continuously in a loop using a script sometimes throws a timeout error
Is it due to the WebDriverWait function or something else?
@youhaveme9 you're correct. The TimeoutError
appears because WebDriverWait cannot find the element in the defined time period.
For debugging, I suggest the following:
- Don't run the test suite with SELENIUM_HEADLESS. Change the
headless
key tofalse
, so you will observe what selenium is doing with the web browser.
docker-openwisp/tests/config.json
Line 3 in b0bcaed
"headless": true, |
- When running the test suite in loop, pause the execution with
ipdb
so you can inspect the problematic webpage. (You will need to install ipdb withpip install ipdb
in your venv)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran the tests a few times and it finally failed at the 4th attempt:
https://github.com/openwisp/docker-openwisp/actions/runs/12749591277/job/35931588981?pr=430
Hey @pandafy Traceback (most recent call last):
File "/workspaces/docker-openwisp/tests/runtests.py", line 136, in setUpClass
cls.base_driver = webdriver.Chrome(options=options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/codespace/.python/current/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
super().__init__(
File "/home/codespace/.python/current/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in __init__
super().__init__(command_executor=executor, options=options)
File "/home/codespace/.python/current/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in __init__
self.start_session(capabilities)
File "/home/codespace/.python/current/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/codespace/.python/current/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
self.error_handler.check_response(response)
File "/home/codespace/.python/current/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: probably user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir``` |
I provided some instructions on running only the flaky test continuously: |
The error message of the failed build is different though:
Which means there's been some progress! |
Checklist
Reference to Existing Issue
Closes #347
Please open a new issue if there isn't an existing issue yet.