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 ...
随机推荐
- 字符串在forEach方法里面可以使用include函数
今天在写项目的时候,发现了一个问题,使用forEach函数,arr数组里面的字符串可以调用include方法,我查阅了很多地方,string里面没有这个方法. 但是在forEach函数里面确实可以这样 ...
- 零基础逆向工程23_PE结构07_重定位表_IAT表(待补充)
重定位表 待补充 IAT表 待补充
- 带你零基础入门redis【二】
本篇文章介绍redis如何设置开机自启动以及如何在java中应用 一.设置redis开机自启 1.修改redis配置 [root@VM_6_102_centos ~]# vim /usr/local/ ...
- LoadRunner问题解决
1.问题:复制脚本,修改后并保存,直接在controller中加载脚本,无法创建用户,出现“Loadrunner Controller cannot create Vusers. Ensure th ...
- 机器学习经典算法之SVM
SVM 的英文叫 Support Vector Machine,中文名为支持向量机.它是常见的一种分类方法,在机器学习中,SVM 是有监督的学习模型. 什么是有监督的学习模型呢?它指的是我们需要事先对 ...
- jsp四大作用域之request
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding= ...
- 爬取豆瓣电影top250并存储到mysql数据库
import requests from lxml import etree import re import pymysql import time conn= pymysql.connect(ho ...
- python_84_os模块
'os模块:提供对操作系统进行调用的接口' import os print(os.getcwd())#获取当前脚本工作目录,即当前Python脚本工作的目录路径 os.chdir('C:\\Users ...
- js判断是否为app
var ua = navigator.userAgent; var isapp = ua.match("lenovomallapp") == null ? 0 : 1;
- tcp 高性能服务, netty,mqtt
1. io 线程不要有比较长的服务. 全部异步化. [1] netty 权威指南上只是说业务复杂时派发到业务线程池种. 共用的线程池最好都轻量. 多层线程池后, 下层的可以进行隔离. 这个是 mqtt ...