下载文件
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处理文件下载的更多相关文章

  1. Python+Selenium+webdriver环境搭建(windows)以及相关资源下载链接

    今天记录一下测试小菜鸟alter在测试入门的一点关于python+Selenium+webdriver环境搭建的经历以及资源分享.欢迎交流学习,批评指正. 一.Python的下载与安装 1.pytho ...

  2. selenium webdriver API

    元素定位 #coding=utf-8 from selenium import webdriver from selenium.webdriver.firefox.firefox_binary imp ...

  3. Selenium WebDriver Api 知识梳理

    之前一直没有系统的梳理WebDriver Api的相关知识,今天借此机会整理一下. 1.页面元素定位 1.1.8种常用定位方法 # id定位 driver.find_element_by_id() # ...

  4. Selenium WebDriver Code

    Selenium WebDriver 用于模拟浏览器的功能,可以做网站测试用,也可以用来做crawler.我是用eclipse开发的,导入selenium-server-standalone-***. ...

  5. 使用httpclient 调用selenium webdriver

    结合上次研究的selenium webdriver potocol ,自己写http request调用remote driver代替selenium API selenium web driver ...

  6. selenium webdriver 右键另存为下载文件(结合robot and autoIt)

    首先感谢Lakshay Sharma 大神的指导 最近一直在研究selenium webdriver右键菜单,发现selenium webdriver 无法操作浏览器右键菜单,如图 如果我想右键另存为 ...

  7. Selenium Webdriver java 积累一

    Selenium Webdriver 学习: http://jarvi.iteye.com/category/203994 https://github.com/easonhan007/webdriv ...

  8. Selenium的PO模式(Page Object Model)|(Selenium Webdriver For Python)

            研究Selenium + python 自动化测试有近两个月了,不能说非常熟练,起码对selenium自动化的执行有了深入的认识. 从最初无结构的代码,到类的使用,方法封装,从原始函数 ...

  9. Selenium Webdriver下click失效问题解决

    最近在使用Selenium Webdriver(Selenium2.0)进行界面自动化测试的时候发现单击事件无效,通过driver.findElement的方式是可以找到click元素的,但是就是cl ...

随机推荐

  1. OpenStack入门之【OpenStack-havana】之单网卡-All In One 安装(基于CentOS6.4)

    这篇文章是自己的一篇老文,分享下,请君慢用.... =========================================== [特别申明]:经过了一段时间的不断学习加不断的测试得出本文, ...

  2. Coding和Git的环境搭建

    Github太慢了.打开网页慢,下载也只有几kb. 于是找了国内的Git,据说coding不错.就申请了个. 其实csdn也有...但是没人家的专业... 1 注册coding  https://co ...

  3. iOS学习笔记06—Category和Extension

    iOS学习笔记06—Category和Extension 一.概述 类别是一种为现有的类添加新方法的方式. 利用Objective-C的动态运行时分配机制,Category提供了一种比继承(inher ...

  4. java常用数据格式转化,类似数据库group by cube rollup

    java常用数据格式转化,类似数据库group by cube rollup单循环一条sql返回格式如:List<Map<String, List<Record>>> ...

  5. OSS命令行工具ossutil

    ossutil工具旨在为您提供一个以命令行方式管理OSS数据的途径.当前版本未提供完整的Bucket和Multipart管理功能,相关功能会在后续版本中开发.如果您需要使用上述功能,建议先使用ossc ...

  6. jQuery的下面是动态表格动态表单中的HTML代码

    动态表格动态表单中的Jquery代码 <script type="text/javascript" src="/include/jquery/jquery-1.1. ...

  7. hdu5955 Guessing the Dice Roll【AC自动机】【高斯消元】【概率】

    含高斯消元模板 2016沈阳区域赛http://acm.hdu.edu.cn/showproblem.php?pid=5955 Guessing the Dice Roll Time Limit: 2 ...

  8. hdu5692【dfs序】【线段树】

    Snacks Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

  9. 企业证书安装App

    通过苹果自带的浏览器访问:itms-services:///?action=download-manifest&url=https://www.xxxx.com:xxx/xxxx/xxx.pl ...

  10. 编译android --system,framework

    在你的android 目录下: sudo git clone  https://android.googlesource.com/platform/manifest cd manifest git b ...