diff options
author | Alassane Yattara <alassane.yattara@savoirfairelinux.com> | 2023-11-29 23:54:08 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-12-02 18:04:22 +0000 |
commit | 715898cb9a2688957120d0286dc136db1298f9de (patch) | |
tree | fdb076b15772f4be2721dbfd587b978416c38a14 /bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | |
parent | c55cb443d029e15da45802c9bf1d7e82a72bb15d (diff) | |
download | poky-715898cb9a2688957120d0286dc136db1298f9de.tar.gz |
bitbake: toaster/tests: Update methods wait_until_~ to skip using time.sleep
Update Class Wait from selenium_helpers_base, to override
wait_until_visible and wait_until_present with poll argument to better
handle delay between driver actions
(Bitbake rev: 486817ac6ad28580d81dcf6e3789678d9259bb54)
Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/tests/browser/selenium_helpers_base.py')
-rw-r--r-- | bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py index e0ac43768e..d9ea7fd108 100644 --- a/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py +++ b/bitbake/lib/toaster/tests/browser/selenium_helpers_base.py | |||
@@ -71,7 +71,9 @@ class Wait(WebDriverWait): | |||
71 | _TIMEOUT = 10 | 71 | _TIMEOUT = 10 |
72 | _POLL_FREQUENCY = 0.5 | 72 | _POLL_FREQUENCY = 0.5 |
73 | 73 | ||
74 | def __init__(self, driver): | 74 | def __init__(self, driver, timeout=_TIMEOUT, poll=_POLL_FREQUENCY): |
75 | self._TIMEOUT = timeout | ||
76 | self._POLL_FREQUENCY = poll | ||
75 | super(Wait, self).__init__(driver, self._TIMEOUT, self._POLL_FREQUENCY) | 77 | super(Wait, self).__init__(driver, self._TIMEOUT, self._POLL_FREQUENCY) |
76 | 78 | ||
77 | def until(self, method, message=''): | 79 | def until(self, method, message=''): |
@@ -175,18 +177,19 @@ class SeleniumTestCaseBase(unittest.TestCase): | |||
175 | """ Return the element which currently has focus on the page """ | 177 | """ Return the element which currently has focus on the page """ |
176 | return self.driver.switch_to.active_element | 178 | return self.driver.switch_to.active_element |
177 | 179 | ||
178 | def wait_until_present(self, selector): | 180 | def wait_until_present(self, selector, poll=0.5): |
179 | """ Wait until element matching CSS selector is on the page """ | 181 | """ Wait until element matching CSS selector is on the page """ |
180 | is_present = lambda driver: self.find(selector) | 182 | is_present = lambda driver: self.find(selector) |
181 | msg = 'An element matching "%s" should be on the page' % selector | 183 | msg = 'An element matching "%s" should be on the page' % selector |
182 | element = Wait(self.driver).until(is_present, msg) | 184 | element = Wait(self.driver, poll=poll).until(is_present, msg) |
183 | return element | 185 | return element |
184 | 186 | ||
185 | def wait_until_visible(self, selector): | 187 | def wait_until_visible(self, selector, poll=1): |
186 | """ Wait until element matching CSS selector is visible on the page """ | 188 | """ Wait until element matching CSS selector is visible on the page """ |
187 | is_visible = lambda driver: self.find(selector).is_displayed() | 189 | is_visible = lambda driver: self.find(selector).is_displayed() |
188 | msg = 'An element matching "%s" should be visible' % selector | 190 | msg = 'An element matching "%s" should be visible' % selector |
189 | Wait(self.driver).until(is_visible, msg) | 191 | Wait(self.driver, poll=poll).until(is_visible, msg) |
192 | time.sleep(poll) # wait for visibility to settle | ||
190 | return self.find(selector) | 193 | return self.find(selector) |
191 | 194 | ||
192 | def wait_until_focused(self, selector): | 195 | def wait_until_focused(self, selector): |