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 - 移动端 常见小bug整理与解决方法总结【更新中】
常见问题总结与整理系列~ 1. border一像素在手机上看着有点粗的问题: 原理是因为:1px在手机上是使用2dp进行渲染的.换成 border: 0.5像素?是不行的! 解决方法: 把border ...
- HP P2xxx/MSA SMI-S Provider
HP P2xxx/MSA SMI-S Provider The HP MSA provider must be enabled before it can be monitored. For more ...
- intellij idea移动至方法块function()末尾的快捷键
intellij idea移动至方法块末尾的快捷键: 1. move caret to code block end ctrl+] 2. move caret to code block end wi ...
- SDWebImage第三方库使用注意的一些问题
1.利用"UIImageView+WebCache.h"加载图片数据 例如: UIImage *placeHolderImg = [UIImage imageNamed:@&quo ...
- Linux下 磁盘扩容的两种方式
Hadoop扩容 概述 Hadoop存储容量或计算能力不能满足日益增长的需求时,就需要扩容. 扩容有两个方案: 1) 增加磁盘 2) 增加节点 方案一:扩大虚拟磁盘 扩大容量 将虚拟的Linux关闭, ...
- ZooKeeper (一)概览
注:出于记录对 zookeeper 的学习研究成果目的,并分享经验,根据官方文档翻译整理而成本文,原文地址: http://zookeeper.apache.org/doc/trunk/zookeep ...
- TOP100summit:【分享实录-封宇】58到家多端消息整合之路
本篇文章内容来自2016年TOP100summit 58到家架构师封宇的案例分享. 编辑:Cynthia 2017年11月9-12日北京国家会议中心第六届TOP100summit,留言评论有机会获得免 ...
- htop详解
一.Htop的使用简介 大家可能对top监控软件比较熟悉,今天我为大家介绍另外一个监控软件Htop,姑且称之为top的增强版,相比top其有着很多自身的优势.如下: 两者相比起来,top比较繁琐 默认 ...
- 网络层 运输层 NAT路由器 NATP路由器 一根光纤 多个固定ip
长城宽带想要公网和固定ip的来看看吧.[迅雷赚钱宝吧]_百度贴吧 https://tieba.baidu.com/p/4035318158?red_tag=0898389066 连续电话投诉加咨询一周 ...
- Lost connection to MySQL server during query ([Errno 104] Connection reset by peer)
Can't connect to MySQL server Lost connection to MySQL server during query · Issue #269 · PyMySQL/Py ...