selenium WebDriver处理文件下载
下载文件
WebDriver 允许我们设置默认的文件下载路径。也就是说文件会自动下载并且存在设置的那个目录
中。下面以FireFox 为例执行文件的下载。
package com.mypro.jase;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
public class download {
public static void main(String[] args){
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("browser.download.folderList",2); //设置成0 代表下载到浏览器默认下载路径;设置成2 则可以保存到指定目录。
firefoxProfile.setPreference("browser.download.manager.showWhenStarting",false); //是否显示开始,Ture 为显示,Flase 为不显示。
firefoxProfile.setPreference("browser.download.dir","d:\\java"); //用于指定你所下载文件的目录。
firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/octet-stream");
//指定要下载页面的Content-type 值,“application/octet-stream”为文件的类型
WebDriver driver = new FirefoxDriver(firefoxProfile);
driver.get("https://pypi.Python.org/pypi/selenium");
driver.findElement(By.partialLinkText("selenium-2")).click();
}
}
selenium WebDriver处理文件下载的更多相关文章
- Python+Selenium+webdriver环境搭建(windows)以及相关资源下载链接
今天记录一下测试小菜鸟alter在测试入门的一点关于python+Selenium+webdriver环境搭建的经历以及资源分享.欢迎交流学习,批评指正. 一.Python的下载与安装 1.pytho ...
- selenium webdriver API
元素定位 #coding=utf-8 from selenium import webdriver from selenium.webdriver.firefox.firefox_binary imp ...
- Selenium WebDriver Api 知识梳理
之前一直没有系统的梳理WebDriver Api的相关知识,今天借此机会整理一下. 1.页面元素定位 1.1.8种常用定位方法 # id定位 driver.find_element_by_id() # ...
- Selenium WebDriver Code
Selenium WebDriver 用于模拟浏览器的功能,可以做网站测试用,也可以用来做crawler.我是用eclipse开发的,导入selenium-server-standalone-***. ...
- 使用httpclient 调用selenium webdriver
结合上次研究的selenium webdriver potocol ,自己写http request调用remote driver代替selenium API selenium web driver ...
- selenium webdriver 右键另存为下载文件(结合robot and autoIt)
首先感谢Lakshay Sharma 大神的指导 最近一直在研究selenium webdriver右键菜单,发现selenium webdriver 无法操作浏览器右键菜单,如图 如果我想右键另存为 ...
- Selenium Webdriver java 积累一
Selenium Webdriver 学习: http://jarvi.iteye.com/category/203994 https://github.com/easonhan007/webdriv ...
- Selenium的PO模式(Page Object Model)|(Selenium Webdriver For Python)
研究Selenium + python 自动化测试有近两个月了,不能说非常熟练,起码对selenium自动化的执行有了深入的认识. 从最初无结构的代码,到类的使用,方法封装,从原始函数 ...
- Selenium Webdriver下click失效问题解决
最近在使用Selenium Webdriver(Selenium2.0)进行界面自动化测试的时候发现单击事件无效,通过driver.findElement的方式是可以找到click元素的,但是就是cl ...
随机推荐
- css笔记 - 张鑫旭css课程笔记之 border 篇
border地址 border特性: 能形成BFC但是不能清除浮动.但是bfc也是把子元素的margin包裹进来,但是拿自己的margin穿透没办法的. 边框宽度不支持百分比 透明border可以突破 ...
- jade(pug)学习笔记(待填充.......)
深刻认识到总结知识点的重要性,不然遇到似曾相识的问题,要翻老半天的百度才能解决.20171018 pug——文字内部嵌入结构 比如: <a class = "href"> ...
- 原生js--键盘事件
键盘事件知识点: 1.如果用户按键事件足够长,在keyup事件触发之前,会触发多次keydown事件 2.通过keyCode(charCode firefox)指定按下的是哪个键,采用unicode编 ...
- Android开发进阶从小工到专家之性能优化
- Redis学习笔记--Redis配置文件redis.conf参数配置详解
########################################## 常规 ########################################## daemonize n ...
- 题目1002:Grading(题目背景基于高考打分的简单判断)
题目链接:http://ac.jobdu.com/problem.php?pid=1002 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...
- The request associated with the AsyncContext has already completed processing
Some time ago there was a problem with the servlet3.0, is in servlet in asynchronous processing data ...
- IOS 7 更改导航栏文字到白色
To hide status bar in any viewcontroller: -(BOOL) prefersStatusBarHidden { return YES; } To change t ...
- C# 读取xml时,遇到xmlns的问题
1.读取xml的时候,由于xml里有xmlns的属性,导致了读xml无法正常读取.通过网上搜索,发现需要先注册命名空间. xmlns是XML Namespaces的缩写,中文名称是XML(标准通用标 ...
- 关于卸载vmware后如何删除VMware Network Adapter VMnet1虚拟网卡
默认情况下.我们在windows下安装了vmware虚拟机后,都会产生VMware Network Adapter VMnet1虚拟网卡 对于vmware虚拟网卡的管理,我们可以在vmware虚拟机软 ...