导航

[Selenium3+python3.6]自动化测试2-入门

Posted on 2017-03-17 11:03  carol2000  阅读(157)  评论(0编辑  收藏  举报

参考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()