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

[tests] Fixed flaky test_topology_graph #430

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

youhaveme9
Copy link
Contributor

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #347

Please open a new issue if there isn't an existing issue yet.

Comment on lines +165 to +167
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, path))
)
Copy link
Member

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

Suggested change
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.

Copy link
Member

@pandafy pandafy left a 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:

  1. Don't run the test suite with SELENIUM_HEADLESS. Change the headless key to false, so you will observe what selenium is doing with the web browser.

"headless": true,

  1. 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 with pip install ipdb in your venv)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] Flaky test: test_topology_graph
2 participants