Esempio n. 1
0
 def wait_find_element(self, by_type: str = By.ID, value: str = None, driver: WebDriver = None):
     """
     获取单个元素, 显式等待
     :param driver: 驱动对象
     :param by_type: 查找元素的操作
     :param value: 查找元素的方法
     :return:
     """
     try:
         driver = driver or self.driver
         if not driver:
             return driver
         WebDriverWait(driver, 15).until(
             EC.presence_of_element_located(locator=(by_type, value)))
         return driver.find_element(by_type, value)
     except:
         return None
Esempio n. 2
0
 def wait_find_element(self, by_type: str, value: str, driver: WebDriver = None):
     """
     获取单个元素, 显式等待
     :param driver: 驱动对象
     :param by_type: 查找元素的操作
     :param value: 查找元素的方法
     :return:
     """
     driver = driver or self.driver
     if not driver:
         return driver
     try:
         WebDriverWait(driver, 10).until(EC.visibility_of_element_located(locator=(by_type, value)))
         return driver.find_element(by_type, value)
     except:
         # self.logger.warning(traceback.format_exc())
         return False
Esempio n. 3
0
def findelement(driver: WebDriver, by: By, value: str):
    try:
        driver.find_element(by=by, value=value)
        return True
    except NoSuchElementException:
        return False