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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ def select_resource(self, name, driver=None):
path = (
f'//a[contains(text(), "{name}")]/../../' '/input[@name="_selected_action"]'
)
driver.find_element(By.XPATH, path).click()

element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, path))
)
Comment on lines +165 to +167
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.

element.click()

def action_on_resource(self, name, path, option, driver=None):
"""Perform an action on a resource.
Expand All @@ -178,8 +182,9 @@ def action_on_resource(self, name, path, option, driver=None):
driver = self.base_driver
driver.get(f"{self.config['app_url']}{path}")
self.select_resource(name)
driver.find_element(By.NAME, 'action').find_element(
By.XPATH, f'//option[@value="{option}"]'
element = driver.find_element(By.NAME, 'action')
WebDriverWait(element, 10).until(
EC.presence_of_element_located((By.XPATH, f'//option[@value="{option}"]'))
).click()
driver.find_element(By.NAME, 'index').click()

Expand Down
Loading