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 ...
随机推荐
- JavaScript_3_输出
1. JavaScript通常用于操作HTML元素,可以使用getElementById(id)方法. JavaScript由Web浏览器来执行. 2. document.write()仅仅向文档输出 ...
- IIS 7.0的根文件(applicationHost.config)位置及说明
位置 C:\Windows\System32\inetsrv\config\applicationHost.config 说明 https://www.microsoft.com/taiwan/tec ...
- python基础教程总结9——模块,包,标准库
1. 模块 在python中一个文件可以被看成一个独立模块,而包对应着文件夹,模块把python代码分成一些有组织的代码段,通过导入的方式实现代码重用. 1.1 模块搜索路径 导入模块时,是按照sys ...
- Python -- 函数之推导式
5.12 推导式 l = [] for i in range(1,11): l.append(i) print(l) # 用列表推导式 (一行搞定) l = [i for i in range(1,1 ...
- windbg双机调试配置
环境 虚拟机 win7 Pro x86 vmware 12 windbg x86 虚拟机win7配置 管理员权限运行cmd.exe 然后输入以下命令: bcdedit /? bcdedit /enum ...
- 机器学习十大常用算法(CITE 不会停的蜗牛 ) interesting
算法如下: 决策树 随机森林算法 逻辑回归 SVM 朴素贝叶斯 K最近邻算法 K均值算法 Adaboost 算法 神经网络 马尔可夫 1. 决策树 根据一些 feature 进行分类,每个节点提一个问 ...
- java中求几个字符串的最大公共子串 使用了比较器Comparator
package com.swift; import java.util.ArrayList; import java.util.Collections; import java.util.Compar ...
- c++ sort用法 学习笔记
c++ sort排序函数,需要加库#include<algorithm>,语法描述:sort(begin,end,cmp),cmp参数可以没有,如果没有默认非降序排序. 首先是升序排序: ...
- Flask-数据与路由
数据 图书数据库的地址 # 基地址 http://t.yushu.im # 关键字搜索 http://t.yushu.im/v2/book/search?q={}&start={}&c ...
- PHP函数详解:call_user_func()使用方法
call_user_func函数类似于一种特别的调用函数的方法,使用方法如下: <?php function nowamagic($a,$b) { echo $a; echo $b; } cal ...