Skip to content

Commit

Permalink
Fix race condition in PF4 progressbar (#1448)
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

(cherry picked from commit 1661b6c)
  • Loading branch information
dosas authored and ogajduse committed Aug 16, 2024
1 parent f554066 commit 7e27eb1
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 @@ -2239,6 +2239,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 @@ -2247,7 +2255,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 7e27eb1

Please sign in to comment.