def wait_presence_alert(self): try: return WebDriverWait(self.driver, 30).until(EC.alert_is_present()) except (NoSuchElementException, TimeoutException) as e: do_logger.error('定位出错:{}'.format(e)) # 保存错误截图 self.save_screenshot()
def wait_presence_element(self, locator): try: return WebDriverWait(self.driver, 20).until( EC.presence_of_element_located(locator)) except (NoSuchElementException, TimeoutException) as e: do_logger.error('定位出错:{}'.format(e)) # 保存错误截图 self.save_screenshot()
def wait_visible_element(self, locator): try: return WebDriverWait(self.driver, 20).until( EC.visibility_of_element_located(locator)) except (TimeoutException, NoSuchElementException) as e: do_logger.error("定位出错: {}".format(e)) # 保存错误截图 self.save_screenshot()
def wait_click_element(self, locator): try: return WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable(locator)) except (TimeoutException, NoSuchElementException) as e: do_logger.error('定位出错:{}'.format(e)) # 保存错误截图 self.save_screenshot()
def find_element(self, locator): try: return self.driver.find_element(*locator) except NoSuchElementException as e: do_logger.error("定位出错:{}".format(e)) self.save_screenshot()