From 9c80b40ee5a98cf6e7b1cda6b2951b178ac28524 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 18 Oct 2024 22:41:28 +0100 Subject: [PATCH] bitbake: toaster/tests/browser/helpers: Drop remains of polling/sleep calls Drop the remaining poll parameters from the helpers code along with the remaining sleep call since the tests no longer depend on this. This has the nice benefit of significantly speeding up the toaster test runs (45 minutes down to 12 minutes overall). If a parameter is needed, it should be the timeout, not the polling frequency. (Bitbake rev: 6de912e4f278ffd694fb2258482081dc3bc61c7a) Signed-off-by: Richard Purdie --- .../tests/browser/selenium_helpers_base.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py index b664166055..45eabaf1ce 100644 --- a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py +++ b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py @@ -186,7 +186,7 @@ class SeleniumTestCaseBase(unittest.TestCase): self.driver.get(abs_url) try: # Ensure page is loaded before proceeding - self.wait_until_visible("#global-nav", poll=3) + self.wait_until_visible("#global-nav") except NoSuchElementException: self.driver.implicitly_wait(3) except TimeoutException: @@ -211,20 +211,18 @@ class SeleniumTestCaseBase(unittest.TestCase): """ Return the element which currently has focus on the page """ return self.driver.switch_to.active_element - def wait_until_present(self, selector, poll=0.5): + def wait_until_present(self, selector, timeout=Wait._TIMEOUT): """ Wait until element matching CSS selector is on the page """ is_present = lambda driver: self.find(selector) msg = 'An element matching "%s" should be on the page' % selector - element = Wait(self.driver, poll=poll).until(is_present, msg) - if poll > 2: - time.sleep(poll) # element need more delay to be present + element = Wait(self.driver, timeout=timeout).until(is_present, msg) return element - def wait_until_visible(self, selector, poll=1): + def wait_until_visible(self, selector, timeout=Wait._TIMEOUT): """ Wait until element matching CSS selector is visible on the page """ is_visible = lambda driver: self.find(selector).is_displayed() msg = 'An element matching "%s" should be visible' % selector - Wait(self.driver, poll=poll).until(is_visible, msg) + Wait(self.driver, timeout=timeout).until(is_visible, msg) return self.find(selector) def wait_until_not_visible(self, selector, timeout=Wait._TIMEOUT): @@ -234,15 +232,14 @@ class SeleniumTestCaseBase(unittest.TestCase): Wait(self.driver, timeout=timeout).until_not(is_visible, msg) return self.find(selector) - def wait_until_clickable(self, selector, poll=1): + def wait_until_clickable(self, selector, timeout=Wait._TIMEOUT): """ Wait until element matching CSS selector is visible on the page """ sel = selector if sel.startswith('#'): sel = selector[1:] WebDriverWait( self.driver, - Wait._TIMEOUT, - poll_frequency=poll + timeout=timeout, ).until( EC.element_to_be_clickable((By.ID, sel )