浏览器的后退操作(back)
# coding=utf-8
import time
from selenium import webdriver
driver = webdriver.Firefox()
driver.maximize_window()
driver.get("http://www.baidu.com")
time.sleep(2)
driver.find_element_by_xpath('/html/body/div[1]/div[1]/div/div[3]/a[1]').click()
time.sleep(2)
print driver.title
'''
执行后退操作
'''
driver.back()
print driver.title
time.sleep(2)
浏览器的前进操作(forward)
# coding=utf-8
import time
from selenium import webdriver
driver = webdriver.Firefox()
driver.maximize_window()
driver.get("http://www.baidu.com")
time.sleep(2)
driver.find_element_by_xpath('/html/body/div[1]/div[1]/div/div[3]/a[1]').click()
time.sleep(2)
print u'标题1:'+driver.title
'''
执行后退操作
'''
driver.back()
print u'标题2:'+driver.title
time.sleep(2)
'''
执行前进操作
'''
driver.forward()
print u'标题3:'+driver.title
浏览器刷新操作(refresh)
# coding=utf-8
import time
from selenium import webdriver
driver = webdriver.Firefox()
driver.maximize_window()
driver.get("http://www.baidu.com")
time.sleep(2)
driver.find_element_by_xpath('/html/body/div[1]/div[1]/div/div[3]/a[1]').click()
time.sleep(2)
title1=driver.title
print u'标题1:'+title1
'''
执行后退操作
'''
driver.refresh()
title2=driver.title
print u'标题2:'+title2
if title1==title2:
print u'刷新成功'
else:
print u'刷新命令错误'
获取浏览器版本号(capabilities['version'])
# coding=utf-8
from selenium import webdriver
driver = webdriver.Firefox()
driver.maximize_window()
'''
打印输出浏览器版本号
'''
print driver.capabilities['version']
自定义浏览器大小
# coding=utf-8
from selenium import webdriver
driver = webdriver.Firefox()
driver.maximize_window()
#打印输出浏览器分辨率
print driver.get_window_size()
'''
控制浏览器大小(set_window_size)
'''
driver.set_window_size(800,800)
欢迎关注微信公众平台我要学测试,扫码关注!
网友评论