Selenium WebDriver的多浏览器测试
1. IE浏览器,需要配合下载IEDriverSever.exe的驱动程序,目前selenium支持IE9以上。
(驱动程序下载链接:https://pan.baidu.com/s/1YpaUsIs128znSOBQmHdzWw 密码: mxfq)。
访问搜狗主页的脚本:
#VisitSogouByIE.py 访问搜狗主页例子 #encoding=utf-8
from selenium import webdriver
import unittest class VisitSogouByIE(unittest.TestCase): def setUp(self):
# 启动IE浏览器
self.driver = webdriver.Ie(executable_path = "e:\\IEDriverServer") def test_visitSogou(self):
# 访问搜索首页
self.driver.get("http://www.sogou.com")
# 打印当前网页的网址
print self.driver.current_url def tearDown(self):
# 退出IE浏览器
self.driver.quit() if __name__ == '__main__':
unittest.main()
#encoding=utf-8
from selenium import webdriver
import unittest
class VisitSogouByIE(unittest.TestCase):
def setUp(self):
# 启动IE浏览器
self.driver = webdriver.Ie(executable_path = "e:\\IEDriverServer")
def test_visitSogou(self):
# 访问搜索首页
self.driver.get("http://www.sogou.com")
# 打印当前网页的网址
print self.driver.current_url
def tearDown(self):
# 退出IE浏览器
self.driver.quit()
if __name__ == '__main__':
unittest.main()
2. Firefox浏览器,需要配合下载geckoDriver.exe的驱动程序
(驱动程序下载地址:https://pan.baidu.com/s/16X-dRmSzrUx-r1rIaCnQFw 密码: ra79)
访问搜狗主页的脚本:
#encoding=utf-8
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium import webdriver
import unittest class VisitSogouByFirefox(unittest.TestCase): def setUp(self):
#binary = FirefoxBinary('D:\\FirefoxPortable\\Firefox.exe')
# 启动Firefox浏览器
self.driver = webdriver.Firefox(executable_path = "e:\\geckodriver")
#driver = webdriver.Firefox(firefox_binary = binary,executable_path = r"c:\geckodriver")
def test_visitSogou(self):
# 访问搜索首页
self.driver.get("http://www.sogou.com")
# 打印当前网页的网址
print self.driver.current_url def tearDown(self):
# 退出firefox浏览器
self.driver.quit() if __name__ == '__main__':
unittest.main()
3. Firefox浏览器,需要配合下载 chromedriver.exe的驱动程序
(驱动程序下载地址:https://pan.baidu.com/s/1Sei0ZkcjNYBsdNUKPEgKYg 密码: br6s)
访问搜狗主页的脚本:
#encoding=utf-8
from selenium import webdriver
import unittest class VisitSogouByChrome(unittest.TestCase): def setUp(self):
# 启动Chrome浏览器
self.driver = webdriver.Chrome(executable_path = "E:\\chromedriver") def test_visitSogou(self):
# 访问搜索首页
self.driver.get("http://www.sogou.com")
# 打印当前网页的网址
print self.driver.current_url def tearDown(self):
# 退出IE浏览器
self.driver.quit() if __name__ == '__main__':
unittest.main()
Selenium WebDriver的多浏览器测试的更多相关文章
- Selenium WebDriver使用IE浏览器
摘:http://www.cnblogs.com/dream0577/archive/2012/10/07/2714579.html /** 用IE驱动,1.先到官网下载IEDriverS ...
- selenium webdriver启动Chrome浏览器后无法输入网址的解决办法
通过selenium webdriver启动Chrome浏览器,脚本如下: from selenium import webdriver browser = webdriver.Chrome() br ...
- selenium webdriver启动IE浏览器失败的解决办法
通过selenium webdriver启动IE浏览器失败,报错:selenium.common.exceptions.WebDriverException: Message: Unexpected ...
- selenium webdriver 启动三大浏览器Firefox,Chrome,IE
selenium webdriver 启动三大浏览器Firefox,Chrome,IE 1.安装selenium 在联网的情况下,在Windows命令行(cmd)输入pip install selen ...
- selenium webdriver操作各浏览器
描述 本文主要是针对Chrome 62 , firefox57 ,和IE11 三个版本的操作.相关的driver .可点击以下链接.所有的driver 建议放在浏览器的目录下,本文中所有的driver ...
- Selenium webdriver 操作chrome 浏览器
Step1: 下载chromedriver. 下载路径: http://chromedriver.storage.googleapis.com/index.html 选择一个合适的下载即可.我下载的是 ...
- Selenium webdriver 操作IE浏览器
V1.0版本:直接新建WebDriver使用 import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetE ...
- WebDriver的多浏览器测试的浏览器驱动程序
1.在使用IE浏览器进行WebDriver自动化测试之前,需要从http://docs.seleniumhq.org/download/网站上下载一个WebDriver链接IE浏览器的驱动程序,文件名 ...
- Python+Selenium WebDriver API:浏览器及元素的常用函数及变量整理总结
由于网页自动化要操作浏览器以及浏览器页面元素,这里笔者就将浏览器及页面元素常用的函数及变量整理总结一下,以供读者在编写网页自动化测试时查阅. from selenium import webdrive ...
随机推荐
- BZOJ3004: 吊灯(结论 毒瘤)
题意 $n$个节点的树,判断能否划分成$\frac{n}{k}$个大小为$k$的联通块 Sol 首先$k$必须是$n$的倍数. 然后刚开始我就非常傻的以为输出所有约数就行了.. 但是图是这样,$k = ...
- It is not the destination so much as the journey, they say.
It is not the destination so much as the journey, they say. 人家说目的地不重要,重要的是旅行的过程.<加勒比海盗>
- echarts使用中的那些事儿( 三)
饼图上的那些字与下面说明性的文字有些重合,该怎么缩小圆形的大小呢,还有它的位置,怎么让它向上一些或者向下一些: 有以下两个属性可以解决问题: radius : '55%', ------------这 ...
- CSS冗余简化(持续更新)
1.float属性会把元素默认成inline-block状态,不需要再专门定义display了 2.对于inline而言,您设置line-height多大,很多时候并不需要定义height,其实际占据 ...
- background-size在IE8不兼容问题
background-size在IE8及以下浏览器不兼容:要解决的话要用滤镜: filter: progid: DXImageTransform.Microsoft.AlphaImageLoader( ...
- object flash
<!-- html插入flash --> <object type="application/x-shockwave-flash" width="100 ...
- DA层(数据访问层)的方法不用静态的
1.静态方法,不会经过构造函数,所以你不能通过构造函数来初始参数,你只能通过传递参数,来初始他当你有多种参数需要传递的时候,你就要不断重载他了.当然你可以用参数型的类型,不过如果参数有一定结构,就很麻 ...
- TCP连接建立与关闭
http://hi.baidu.com/psorqkxcsfbbghd/item/70f3bd91943b9248f14215cd TCP连接建立与关闭 TCP 是一个面向连接的协议,无论哪一方向另一 ...
- 最新电脑公司最新GHOST WIN7系统32,64位极速安全版
系统来自系统妈:http://www.xitongma.com 电脑公司最新GHOST win7系统64位极速安全版 V2016年3月 系统简介 电脑公司ghost win7系统64位极速安全版集成了 ...
- python基础教程总结15——6 CGI远程编辑
功能: 将文档作为普通网页显示: 在web表单的文本域内显示文档: 保存表单中的文本: 使用密码保护文档: 容易拓展,支持处理多余一个文档的情况 1.CGI CGI(Comment Gateway I ...