参考http://www.cnblogs.com/yoyoketang/p/6123890.html
1 #coding=utf-8 2 #Import webdriver time module 3 from selenium import webdriver 4 import time 5 driver = webdriver.Firefox() 6 7 driver.get("https://www.baidu.com") 8 time.sleep(3) 9 #refresh page 10 driver.refresh() 11 driver.get("http://cn.bing.com/") 12 #back 13 driver.back() 14 time.sleep(2) 15 #forward 16 driver.forward() 17 #resize window 18 driver.set_window_size(540,960) 19 time.sleep(2) 20 #max window 21 driver.maximize_window() 22 driver.get_screenshot_as_file(r'snap_shot.jpg') 23 #close is for ONLY current winidow 24 #driver.close() 25 #quit is for all the browser proceses 26 driver.quit()