selenium之截图
下面和大家分享一下,ui自动化中截图方法。
代码如下:
def screen_shot(self):
current_time=datatime.fromtimestamp(int(time.time())) #获取当前时间
self.driver.sava_screenshot(os.path.join(IMG_PATH,current_time+‘png‘)) #调用sava_screenshot方法,将报错截图存放在指定目录
获取根目录py文件:
ROOT_PATH=os.path.dirname(os.path.abspath(__file__)) #获取项目路径
LOG_PATH=os.path.join(ROOT_PATH,‘LOG‘) #创建log目录
if not os.path.exists(LOG_PATH):
os.mkdir(LOG_PATH)
IMG_PATH=os.path.join(LOG_PATH,‘img‘) #创建img文件夹
if not os.path.exists(IMG_PATH):
os.mkdir(IMG_PATH)
相关推荐
competeking 2020-07-04
thunderstorm 2020-07-04
Catastrophe 2020-06-11
云之飞踢 2020-05-20
JF0 2020-05-08
houjinkai 2020-01-12
tanyhuan 2020-01-08
DonviYang 2020-01-07
aolishuai 2020-01-05
muzirigel 2019-12-28
CharlesYooSky 2019-12-24
kuwoyinlehe 2019-12-18
JF0 2019-11-29
xiaohouye 2019-11-11
natejeams 2008-01-21
Rain 2019-11-03
yishouwangnian 2019-09-07