from webdriver_helper import webdriver, get_webdriver
from selenium.webdriver import chrome
driver = webdriver.Chrome() # 实例化 ,刚启动浏览器是空白页面
driver.maximize_window() # 窗口最大化
driver.get("http://www.baidu.com/") # 访问网址
png=driver.get_screenshot_as_png()#获取二进制数据 需要手动写入文件 截图
with open("a.png","bw") as f:
f.write(png)
str=driver.get_screenshot_as_base64()#获取字符串 截图
with open("b.text","tw") as f:
f.write(str)
driver.get_screenshot_as_file('c.png')#可不可以是jpg,gif 不可以 截图
driver.quit() # 退出浏览器
标签:webdriver,截图,get,selenium,driver,png
From: https://www.cnblogs.com/cy-xt/p/16826668.html