base--PageBase
import time,osfrom selenium import webdriverfrom cwp.util.logger import loggerlogger = logger(logger=‘base_page‘).getlog()class PageBase(object): def __init__(self,driver = None): if driver is None: os.system(‘taskkill / im chromedriver.exe /f‘) self.driver = webdriver.Chrome() else: self.driver = driver def get_element(self,*locator): logger.info(‘查找元素 %s‘%str(locator)) return self.driver.find_element(*locator) def wait_element(self,*locator): ele = None count = 0 while ele is None: count = count + 1 try: ele = self.driver.find_element(*locator) except: pass flag = ele is not None logger.info("查找元素第%d次 %s %s" %(count,flag,str(locator))) time.sleep(0.1) if count > 99: logger.info("没有找到元素 %s " %str(locator)) break return ele
相关推荐
wikiwater 2020-10-27
IdeaElements 2020-08-19
Sophiego 2020-08-16
Kakoola 2020-08-01
Kakoola 2020-07-29
ELEMENTS爱乐冬雨 2020-07-18
ELEMENTS爱乐小超 2020-07-04
ELEMENTS爱乐小超 2020-07-04
Kakoola 2020-06-28
Feastaw 2020-06-18
Wmeng0 2020-06-14
ELEMENTS爱乐冬雨 2020-06-14
云之高水之远 2020-06-14
哈喽elements 2020-06-14
Feastaw 2020-06-11