python屏幕截图到文件及滑屏

import time,os

driver.get_screenshot_as_file ( ' name.png ' )

nowtime=time.strftime( '%Y-%m-%d_%H_%M_%S',time.localtime(time.time()))  #当前时间

filename=' %sphoto.png' % nowtime       #以时间加'photo'命名的png格式的文件

path=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))  #项目目录

pathname=path+\screenshoot\+filename     #屏幕快照保存在项目目录下的screenshoot文件夹下

driver.get_screenshot_as_file(pathname)

滑屏:JS

js_up = "var q=document.documentElement.scrollTop=1000"
self.driver.execute_script(js_up)
原文地址:https://www.cnblogs.com/jiaoxiaohui/p/10490577.html