def fn(self, entity): try: self._condition.fn(entity) except Exception as reason: return reason raise ConditionMismatchException( ) # todo: add more information to message
def match(self, webelements): actual = [it.text for it in webelements] if not (len(actual) == len(self.expected) and all(lmap(operator.eq, actual, self.expected))): raise ConditionMismatchException(expected=self.expected, actual=actual) return webelements
def match(self, webelements): actual = len(webelements) if not actual >= self.expected: raise ConditionMismatchException(expected='>= {}'.format( self.expected), actual=actual) return webelements
def fn(self, webdriver): actual = webdriver.current_url if not self.expected in actual: raise ConditionMismatchException( message="Page url doesn't contain {}".format(self.expected), expected=self.expected, actual=actual)
def match(self, webelement): actual = webelement.get_attribute("class") if self.expected not in actual.split(): raise ConditionMismatchException( expected=self.expected, actual='class attribute: {}'.format(actual)) return webelement
def fn(self, webdriver): # type: (IWebDriver) -> bool actual = webdriver.title if actual not in self.expected: raise ConditionMismatchException( expected=self.expected, actual=actual)
def match(self, webelements): actual = len(webelements) if not actual == self.expected: raise ConditionMismatchException( expected=self.expected, actual=actual) return webelements
def match(self, webelement): actual = webelement.get_attribute(self.name) if not self.value == actual: raise ConditionMismatchException( expected='{name}="{value}"'.format(name=self.name, value=self.value), actual='{name}="{value}"'.format(name=self.name, value=actual)) return webelement
def fn(self, webdriver): # type: (IWebDriver) -> bool result = webdriver.execute_script(self.script) if not result: raise ConditionMismatchException( expected='''script: {script} \t\t to return: true'''.format(script=self.script), actual='''returned: {result}'''.format(result=result))
def match(self, webelement): # type: (IWebElement) -> IWebElement actual_displayed = webelement.is_displayed() actual_enabled = webelement.is_enabled() if not (actual_displayed and actual_enabled): raise ConditionMismatchException( expected='displayed and enabled', actual='displayed: {displayed}, enabled: {enabled}'.format( displayed=actual_displayed, enabled=actual_enabled)) return webelement
def match(self, webelement): actual_text = webelement.text if not self.expected_text == actual_text: raise ConditionMismatchException(expected=self.expected_text, actual=actual_text) return webelement
def match(self, webelement): # type: (SeleneElement) -> IWebElement if not webelement.is_enabled(): raise ConditionMismatchException() return webelement
def fn(self, webdriver): actual = webdriver.current_url if not self.expected == actual: raise ConditionMismatchException(expected=self.expected, actual=actual)