Python-Selenium2做Web自动化测试(6)-解决使用Webdrive打开Firefox不含有插件的问题
2015-08-09 15:11
721 查看
解决使用Webdrive打开Firefox不含有插件的问题:
一直都存在这个问题,导致打开Firefox速度比较慢,并且不含插件非常影响正常使用。
这时候,我们就会用到firefoxprofile。
首先,介绍一下FirefoxProfile。
要了解Firefox profile请访问 这里 ,它详细解绍了Firefox proflie。在Firefox里,如何管理Firefox profile 请访问 这里 。
既然已经了解过Firefox profile,那么来解决我上面提出的问题。
其实上面的问题很简单,就是使用selenium启动平时使用的Firefox,而不让系统去启动一个新的什么都没有的浏览器。
代码如下:
首先,我先定义我需要使用的profile的文件夹,然后创建一个profile,并且把profile的地址传给它,接着启动firefox的时候传入这个profile,这样,系统再打开的firefox就是我们平时使用的那个了。
一直都存在这个问题,导致打开Firefox速度比较慢,并且不含插件非常影响正常使用。
这时候,我们就会用到firefoxprofile。
首先,介绍一下FirefoxProfile。
要了解Firefox profile请访问 这里 ,它详细解绍了Firefox proflie。在Firefox里,如何管理Firefox profile 请访问 这里 。
既然已经了解过Firefox profile,那么来解决我上面提出的问题。
其实上面的问题很简单,就是使用selenium启动平时使用的Firefox,而不让系统去启动一个新的什么都没有的浏览器。
代码如下:
from selenium import webdriver class Register(unittest.TestCase): def setUp(self): self.profileDir = "\path\your\firefoxprofileDir" self.profile = webdriver.FirefoxProifle(self.profileDir) self.driver = webdriver.Firefox(self.profile) self.driver.implicitly_wait(30) self.base_url = "https://www.example.com/" self.verificationErrors = []
首先,我先定义我需要使用的profile的文件夹,然后创建一个profile,并且把profile的地址传给它,接着启动firefox的时候传入这个profile,这样,系统再打开的firefox就是我们平时使用的那个了。
相关文章推荐
- python中json模块的使用
- 计蒜客 - 挑战难题39 - 斐波那契数列 - Python之路
- python中的类编程
- python中的break|continue|pass|return
- python中的模块以及package的小结
- 2015/8/9 到家了,学完了CodeCademy的Python
- python学习笔记1.2
- Python基本语法
- Python-Selenium2做Web自动化测试(5)-对象事件的操作(鼠标操作、键盘操作)
- Python-Selenium2做Web自动化测试(4)-对象的定位
- win7 64位 安装 scikit-learn和一些python包
- 《python标准库》--string
- python学习笔记1.1
- 【Python】 天气查询
- OS X 安装 VM Fusion 并安装Python3.x 和 Flask 环境
- 2016阿里校招python研发面试
- Python 之 any与all 方法
- python 全排列
- python下载hadoop天气数据
- 小白学Python(三) 几个简单的函数