Merge "New generic _wait_until method which wraps selenium waiting"
This commit is contained in:
@@ -72,20 +72,24 @@ class BaseWebObject(object):
|
|||||||
def _turn_on_implicit_wait(self):
|
def _turn_on_implicit_wait(self):
|
||||||
self.driver.implicitly_wait(self.conf.selenium.page_timeout)
|
self.driver.implicitly_wait(self.conf.selenium.page_timeout)
|
||||||
|
|
||||||
def _wait_till_text_present_in_element(self, element, text, timeout=None):
|
def _wait_until(self, predicate, timeout=None, poll_frequency=0.5):
|
||||||
|
"""Wait until the value returned by predicate is not False or
|
||||||
|
the timeout is elapsed.
|
||||||
|
'predicate' takes the driver as argument.
|
||||||
|
"""
|
||||||
if not timeout:
|
if not timeout:
|
||||||
timeout = self.explicit_wait
|
timeout = self.explicit_wait
|
||||||
wait.WebDriverWait(self.driver, timeout).until(
|
wait.WebDriverWait(self.driver, timeout, poll_frequency).until(
|
||||||
lambda x: self._is_text_visible(element, text))
|
predicate)
|
||||||
|
|
||||||
|
def _wait_till_text_present_in_element(self, element, text, timeout=None):
|
||||||
|
self._wait_until(lambda x: self._is_text_visible(element, text),
|
||||||
|
timeout)
|
||||||
|
|
||||||
def _wait_till_element_visible(self, element, timeout=None):
|
def _wait_till_element_visible(self, element, timeout=None):
|
||||||
if not timeout:
|
self._wait_until(lambda x: self._is_element_displayed(element),
|
||||||
timeout = self.explicit_wait
|
timeout)
|
||||||
wait.WebDriverWait(self.driver, timeout).until(
|
|
||||||
lambda x: self._is_element_displayed(element))
|
|
||||||
|
|
||||||
def _wait_till_element_disappears(self, element, timeout=None):
|
def _wait_till_element_disappears(self, element, timeout=None):
|
||||||
if not timeout:
|
self._wait_until(lambda x: self._is_element_displayed(element),
|
||||||
timeout = self.explicit_wait
|
timeout)
|
||||||
wait.WebDriverWait(self.driver, timeout).until_not(
|
|
||||||
lambda x: self._is_element_displayed(element))
|
|
||||||
|
Reference in New Issue
Block a user