Skip to content
Merged
Changes from 1 commit
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))
)
Copy link
Copy Markdown
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