Пример #1
0
 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()
Пример #2
0
 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()
Пример #3
0
 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()
Пример #4
0
 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()
Пример #5
0
 def find_element(self, locator):
     try:
         return self.driver.find_element(*locator)
     except NoSuchElementException as e:
         do_logger.error("定位出错:{}".format(e))
         self.save_screenshot()