码迷,mamicode.com
首页 > 其他好文 > 详细

base--PageBase

时间:2019-12-26 17:41:41      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:bdr   exe   init   elf   time   logger   class   taskkill   tor   

import time,os
from selenium import webdriver
from cwp.util.logger import logger


logger = 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

base--PageBase

标签:bdr   exe   init   elf   time   logger   class   taskkill   tor   

原文地址:https://www.cnblogs.com/wenjing2019/p/12103253.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!