Skip to content

Commit

Permalink
Fix race condition in PF4 progressbar
Browse files Browse the repository at this point in the history
when the progress bar disappears between the
is_displayed query and the current_progress query
a NoSuchElement exception is raised
  • Loading branch information
dosas committed Jul 4, 2024
1 parent 9fef01a commit 452139b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion airgun/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,14 @@ def read(self):
class PF4ProgressBar(PF4Progress):
locator = './/div[contains(@class, "pf-c-wizard__main-body")]'

@property
def is_completed(self):
"""Boolean value whether progress bar is finished or not"""
try:
return self.current_progress == '100'
except NoSuchElementException:
return False

def wait_for_result(self, timeout=600, delay=1):
"""Waits for progress bar to finish. By default checks whether progress
bar is completed every second for 10 minutes.
Expand All @@ -2241,7 +2249,7 @@ def wait_for_result(self, timeout=600, delay=1):
"""
wait_for(lambda: self.is_displayed, timeout=30, delay=delay, logger=self.logger)
wait_for(
lambda: not self.is_displayed or self.current_progress == '100',
lambda: not self.is_displayed or self.is_completed,
timeout=timeout,
delay=delay,
logger=self.logger,
Expand Down

0 comments on commit 452139b

Please sign in to comment.