Selenium+python-解决使用Webdrive打开Firefox不含有插件的问题
来源:互联网 发布:windows键锁定 编辑:程序博客网 时间:2024/05/17 07:26
原文地址:http://www.cnblogs.com/roicel/archive/2013/03/27/2984551.html?utm_source=tuicool&utm_medium=referral
先看代码(只是一段代码):
from selenium import webdriverclass Register(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() self.driver.implicitly_wait(30) self.base_url = "https://www.example.com/" self.verificationErrors = [] self.accept_next_alert = true
上面这段代码运行的时候,selenium会打开一个新的,不含有任何插件和个人证书的firefox(等同于全新安装后第一次打开的那个firefox)。
但是有些时候,我们希望selenium打开的firefox要有插件或者有已经导入的个人证书,这种情况下,上面的代码就不起作用了。
这时候,我们就会用到firefoxprofile。
首先,介绍一下FirefoxProfile。
要了解Firefox profile请访问这里,它详细解绍了Firefox proflie。在Firefox里,如何管理Firefox profile 请访问这里。
既然已经了解过Firefox profile,那么来解决我上面提出的问题。
其实上面的问题很简单,就是使用selenium启动平时使用的Firefox,而不让系统去启动一个新的什么都没有的浏览器。
代码如下:
from selenium import webdriverclass 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就是我们平时使用的那个了。
0 0
- (selenium 小知识点)解决使用Webdrive打开Firefox不含有插件的问题(python)
- Selenium+python-解决使用Webdrive打开Firefox不含有插件的问题
- 关于selenium 用Webdrive打开Firefox不含有插件的问题(python)
- 关于selenium 用Webdrive打开Firefox不含有插件的问题(python)
- 关于selenium 用Webdrive打开Firefox不含有插件的问题(python)
- Python-Selenium2做Web自动化测试(6)-解决使用Webdrive打开Firefox不含有插件的问题
- Python+Selenium,使用WebDriver启动Firefox,但不打开URL
- Windows环境下使用python selenium 打开Firefox的问题总结
- selenium webdriver 打开带插件的Firefox
- 解决Jenkins运行robot framework selenium脚本不打开浏览器的问题
- 解决Firefox不能打开Applet的问题
- 解决firefox打开flash死机的问题
- x86_64_Fedora9解决Firefox的flash插件问题
- [Python]使用Selenium的webdriver访问页面(Firefox的geckodriver)
- 使用selenium的时候firefox容易出现的问题
- 解决ListView含有CheckBox时ListView不响应的问题
- 解决selenium webdriver运行出现的org.openqa.selenium.firefox.NotConnectedException问题
- 使用Selenium+firefox抓取网页指定firefox_profile后的问题
- Linux 设备驱动开发 —— platform设备驱动应用实例解析
- Fragment ListFragment相关API
- CountDownLatch、CyclicBarrier和Semaphore
- 参与感篇
- Cococs2d-x之解决cocos2d项目编译速度慢的问题
- Selenium+python-解决使用Webdrive打开Firefox不含有插件的问题
- 进程上下文、中断上下文及原子上下文
- IOS性能调优系列:使用Zombies动态分析内存中的僵尸对象
- 290. Word Pattern
- Android应用层View绘制流程与源码分析
- 认识<hr>标签,添加水平横线
- Callable、Future和FutureTask
- <address>标签,为网页加入地址信息
- SpringMVC i18n国际化资源文件路径配置