def assert_element_not_exists(self, element, describe, sleep=0, timeout=10): """ Asserts that the text exists on the current page Args: sleep(int): sleep time element: element describe(str): Assertion description information timeout(int): Maximum waiting time """ time.sleep(sleep) logging.info("预期结果: " + describe + " 元素不存在") for i in range(timeout): element_exists = element.exists() if element_exists is True: insert_assert(describe, False) logging.warn("实际结果: " + describe + " 元素存在") break else: time.sleep(1) continue else: insert_assert(describe, True) logging.info("实际结果: " + describe + " 元素不存在") self.screenshots(describe="断言")
def assert_text_not_exists(self, text: str, describe, sleep=0, timeout=10): """ Asserts that the text exists on the current page Args: sleep(int): sleep time text(str): text describe(str): Assertion description information timeout(int): Maximum waiting time """ time.sleep(sleep) logging.info("预期结果: " + describe + " 文案不存在") for i in range(timeout): text_exists = self.driver(text=text).exists if text_exists is True: insert_assert(describe, False) logging.warn("实际结果: " + describe + " 文案存在") break else: time.sleep(1) continue else: insert_assert(describe, True) logging.info("实际结果: " + describe + " 文案不存在") self.screenshots(describe="断言")
def assert_text_not_equals(text_1, text_2, describe): """ Asserts that two texts are not equal Args: text(list): text """ logging.info("预期结果: " + text_1 + "," + text_2 + " 不相等") if text_1 == text_2: result = [describe, False] Setting.assert_result.append(result) logging.warn("预期结果: " + text_1 + "," + text_2 + " 相等") else: result = [describe, True] Setting.assert_result.append(result) logging.info("预期结果: " + text_1 + "," + text_2 + " 不相等")
def assert_not_contain_text(self, text, describe, sleep=0, timeout=10): """ Asserts that two texts are not equal Args: sleep(int): sleep time text(str): text describe(str): Assertion description information timeout(int): Maximum waiting time """ time.sleep(sleep) text_exists = self.driver(textContains=text).exists(timeout) self.screenshots(describe="断言") logging.info("预期结果: " + describe + " 文案不存在") if text_exists is True: result = [describe, False] Setting.assert_result.append(result) logging.warn("实际结果: " + describe + " 文案存在") else: result = [describe, True] Setting.assert_result.append(result) logging.info("实际结果: " + describe + " 文案不存在")
def assert_element_not_exists(self, element, describe, sleep=0, timeout=10): """ Asserts that the element not exists on the current page Args: sleep(int): sleep time element(object): element object describe(str): Assertion description information """ time.sleep(sleep) element_exists = element.exists(timeout) self.screenshots(describe="断言") logging.info("预期结果: " + describe + " 元素不存在") if element_exists is True: insert_assert(describe, False) logging.warn("实际结果: " + describe + " 元素存在") else: insert_assert(describe, True) logging.info("实际结果: " + describe + " 元素不存在")