selenium截取当前窗口,并保存为图片

# -*- coding:utf-8 -*-

from selenium import webdriver
from time import sleep

driver = webdriver.Firefox()
driver.get('http://www.baidu.com')

driver.find_element_by_id('kw').send_keys('selenium')
driver.find_element_by_id('su').click()
sleep(3)
driver.get_screenshot_as_file('c:/users/os/Desktop/baidu.jpg')
driver.quit()

你可能感兴趣的:(python)