这个是python+selenium之浏览器控制,前进,后退,大小,刷新等
#coding=utf-8
from selenium import webdriver
import time
driver = webdriver.Firefox()
driver.get('http://www.baidu.com')
driver.set_window_size(480,800)
#设置浏览器尺寸大小
time.sleep(2)
driver.maximize_window()
#浏览器全屏
time.sleep(2)
#driver.find_element_by_id("kw").send_keys("selenium")
#通过id定位输入框,后面会讲
#driver.find_element_by_id("su").click()
#通过id定位“百度一下”,后面会讲
#time.sleep(4)
#等等4秒
driver.quit()
#关闭浏览器
#coding=utf-8
#前进和后退
from selenium import webdriver
import time
driver = webdriver.Firefox()
driver.get('http://www.baidu.com')
driver.find_element_by_link_text(u'新闻').click()
time.sleep(2)
driver.back()
time.sleep(2)
driver.forward()
time.sleep(2)
driver.quit()
#coding=utf-8
#刷新
from selenium import webdriver
import time
driver = webdriver.Firefox()
driver.get('http://www.baidu.com')
driver.find_element_by_link_text(u'新闻').click()
time.sleep(2)
driver.refresh()
time.sleep(2)
driver.quit()