diff options
-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): |