def wait_for_value_changed(self, locator, text): e = SaunterWebDriver.find_element_by_locator(locator) for i in range(timeout_seconds): try: if len(e.text.strip()) != 0 and e.text != text: return True except StaleElementReferenceException, e: e = SaunterWebDriver.find_element_by_locator(locator) finally:
def __get__(self, obj, cls=None): try: e = SaunterWebDriver.find_element_by_locator(self.locator) return int(e.text) except AttributeError as e: if str(e) == "'SeleniumWrapper' object has no attribute 'connection'": pass else: raise e except ElementNotFound as e: msg = "Element %s was not found. It is used in the %s page object in the %s module." % (self.locator, obj.__class__.__name__, self.__module__) raise ElementNotFound(msg)
def __get__(self, obj, cls=None): try: e = SaunterWebDriver.find_element_by_locator(self.locator) return int(e.text) except AttributeError as e: if str( e ) == "'SeleniumWrapper' object has no attribute 'connection'": pass else: raise e except ElementNotFound as e: msg = "Element %s was not found. It is used in the %s page object in the %s module." % ( self.locator, obj.__class__.__name__, self.__module__) raise ElementNotFound(msg)
def wait_for_text(self, locator, text): """ Synchronization on some text being displayed in a particular element. :raises: ElementVisiblityTimeout """ for i in range(timeout_seconds): try: e = SaunterWebDriver.find_element_by_locator(locator) if e.text == text: break except: pass time.sleep(1) else: raise ElementTextTimeout("%s value timed out" % locator) return True
def __set__(self, obj, val): e = SaunterWebDriver.find_element_by_locator(self.locator) e.send_keys(val)
def get_meta_element(self, name): return SaunterWebDriver.find_element_by_locator('css=meta[name="%s"]' % name)
def change_collar_style(self, style): before = self.results; SaunterWebDriver.find_element_by_locator(locators["collar style"].replace("REPLACE", style)).click() self.wait_for_value_changed(locators["results"], before)