python+selenium webdriver.firefox()方式配置浏览器设置
webdriver.firefox() 爬虫需求: (其实是输入参数可获取.zip/pdf 文件,然后点击下载)
——但是firefox浏览器有Bug,点击下载之后会有弹出窗口,需要你点击确定,这怎么能成,所以
百度一把:得知需要修改firefox的配置文件mimeTypes.rdf
——搜索栏输入:about:support 配置文件夹—》打开文件夹—》获取文件地址
添加配置内容:
<RDF:Description RDF:about="urn:mimetype:application/zip"
NC:value="application/zip"
NC:editable="true"
NC:fileExtensions="zip"
NC:description="*.zip">
<NC:handlerProp RDF:resource="urn:mimetype:handler:application/zip"/>
</RDF:Description>
<RDF:Seq RDF:about="urn:mimetypes:root">
<RDF:li RDF:resource="urn:mimetype:application/zip"/>
</RDF:Seq>
=====现在下载不需要每次都点击了=====
但是:使用webdriver.firefox()时,程序调用的是一个全新的firefox,所以配置文件并没有起到作用
——程序中可添加FirefoxProfile文件来支持 (FirefoxProfile文件目录就是mimeTypes.rdf的上级目录)
- def __init__(self):
self.url = '+++++++++++++'
profile=webdriver.FirefoxProfile("C:\Users\用户名\AppData\Roaming\Mozilla\Firefox\Profiles\9a71bi5y.default")
self.browser = webdriver.Firefox(profile)
python+selenium webdriver.firefox()方式配置浏览器设置的更多相关文章
- python + selenium WebDriver的环境配置
想试用python语言来学习selenium WebDriver,首先需要搭建一个测试环境,从python安装到浏览器插件配置的详细步骤,总结如下: 一.python环境配置 1.从官网下载最新的一个 ...
- python +selenium +chrome/firefox 环境配置
http://ftp.mozilla.org/pub/firefox/releases/ 各firefox版本下载地址 http://ftp.mozilla.org/pub/firefox/relea ...
- Python Selenium Webdriver常用方法总结
Python Selenium Webdriver常用方法总结 常用方法函数 加载浏览器驱动: webdriver.Firefox() 打开页面:get() 关闭浏览器:quit() 最大化窗口: m ...
- Python+Selenium自动化-安装模块和浏览器驱动操作方法
Python+Selenium自动化-安装模块和浏览器驱动操作方法 1.安装模块文件 pip install selenium 2.安装浏览器驱动 我们主要用的浏览器驱动有chrome浏览器.fire ...
- Python+Selenium+webdriver环境搭建(windows)以及相关资源下载链接
今天记录一下测试小菜鸟alter在测试入门的一点关于python+Selenium+webdriver环境搭建的经历以及资源分享.欢迎交流学习,批评指正. 一.Python的下载与安装 1.pytho ...
- Python selenium.webdriver.chrome.options.Options() Examples
The following are 27 code examples for showing how to use selenium.webdriver.chrome.options.Options( ...
- python selenium webdriver入门基本操作
python selenium webdriver入门基本操作 未经作者允许,禁止转载! from selenium import webdriver import time driver=webdr ...
- Python+Selenium WebDriver API:浏览器及元素的常用函数及变量整理总结
由于网页自动化要操作浏览器以及浏览器页面元素,这里笔者就将浏览器及页面元素常用的函数及变量整理总结一下,以供读者在编写网页自动化测试时查阅. from selenium import webdrive ...
- Selenium webdriver firefox 路径设置问题
问题: Cannot find firefox binary in PATH. Make sure firefox is installed. 原因:selenium找不到Firefox浏览器. 方法 ...
随机推荐
- svnkit递归获取指定目录下的全部文件
package demo.wc; import java.util.Collection; import java.util.Iterator; import org.tmatesoft.svn.co ...
- node-7.2.1 already installed, it's just not linked
直接在terminal下运行以卸载node和nvm: sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,shar ...
- ERROR Review:Unsupported major.minor version 52.0
最近将AS从2.1.2升级至2.2版本后,项目编译报出了如下错误: java.lang.UnsupportedClassVersionError: com/android/build/gradle/L ...
- 使用JQuery做一组复选框的功能。
之前做过复选框的功能,奈何笔记丢失,害的我又鼓捣了一番...还是博客园做笔记比较好. 假设现在有一个表格,每一行都有一个复选框按钮.在表头还有一个全选的复选框按钮. ①.当点击一个全选按钮时,下面的同 ...
- reactnative调研
/** * This function parses the exported methods inside RCTBridgeModules and * generates an array ...
- webpack的正确安装方式
webpack是基于node开发的模块打包工具,所以他本质上是由node实现的. 我们要保持node版本尽量的新,另一个要保持webpack版本尽量的新,高版本的webpack会利用新版本中的一些特性 ...
- ecshop 中如何禁用右键和F12
找到 网站根目录/themes/js/common.js,在最后加入如下代码: //禁用右键和F12 //方法一 document.oncontextmenu = function () { retu ...
- MSF入侵安卓手机
MSF是Metasploit的简称,Metasploit是一款开源的安全漏洞检测工具,非常强大,分别有Windows版和Linux版,工具里集成了许多微软公布的漏洞(0day). 我这里做测试的系统是 ...
- webpack-cli解决办法
错误信息:Error Cannot find module 'webpack-cli 出现这个错误的原因是因为只全局安装了webpack,没有安装对应的webpack-cli.再打包时是需要webpa ...
- java的foreach,后台弹框
for (String string : list) { if(string.equals(ids)){ int res = JOptionPane.showConfirmDialog(null, & ...