selenium结合autoit3实现文件上传及下载
2016-04-15 22:51
791 查看
Au3脚本是AutoIt3 Windows自动安装脚本语言。AutoIt 是一种自动控制工具。它可以被用来自动完成任何基于 Windows 或 DOS 的简单任务。下面将结合selenium来实现文件的上传和下载。
1、首先下载au3(百度搜索autoIt3直接访问官网即可)
2、au3定位文件上传窗口
3、编写au3脚本并compile成对应的*.exe可执行文件以便调用
;ControlFocus("title","text",controlID) Edit1=Edit instance 1
ControlFocus("打开", "","Edit1")
;Wait 10 seconds for the Upload window to appear
WinWait("[CLASS:#32770]","",10)
Sleep(2000)
;Set the File name text on the Edit field
ControlSetText("打开", "", "Edit1", "E:\test\upload.png")
Sleep(2000)
;Click on the Open button
ControlClick("打开", "","Button1");
4、结合selenium实现文件的上传
try {
Runtime.getRuntime().exec("E:\\test\\upload.exe");
} catch (IOException e) {
System.err.println("调用autoit3失败!");
}
5、同理,下载
;ControlFocus("title","text",controlID) Edit1=Edit instance 1
ControlFocus("另存为", "","Edit1")
; Wait 10 seconds for the Upload window to appear
WinWait("[CLASS:#32770]","",10)
; Set input focus to the edit control of Upload window using the handle returned by WinWait
ControlFocus("另存为","","Edit1")
Sleep(2000)
; Set the File name text on the Edit field
ControlSetText("另存为", "", "Edit1", "d:\autoit-v3-setup")
Sleep(2000)
; Click on the Open button
ControlClick("另存为", "","Button1");
1、首先下载au3(百度搜索autoIt3直接访问官网即可)
2、au3定位文件上传窗口
3、编写au3脚本并compile成对应的*.exe可执行文件以便调用
;ControlFocus("title","text",controlID) Edit1=Edit instance 1
ControlFocus("打开", "","Edit1")
;Wait 10 seconds for the Upload window to appear
WinWait("[CLASS:#32770]","",10)
Sleep(2000)
;Set the File name text on the Edit field
ControlSetText("打开", "", "Edit1", "E:\test\upload.png")
Sleep(2000)
;Click on the Open button
ControlClick("打开", "","Button1");
4、结合selenium实现文件的上传
try {
Runtime.getRuntime().exec("E:\\test\\upload.exe");
} catch (IOException e) {
System.err.println("调用autoit3失败!");
}
5、同理,下载
;ControlFocus("title","text",controlID) Edit1=Edit instance 1
ControlFocus("另存为", "","Edit1")
; Wait 10 seconds for the Upload window to appear
WinWait("[CLASS:#32770]","",10)
; Set input focus to the edit control of Upload window using the handle returned by WinWait
ControlFocus("另存为","","Edit1")
Sleep(2000)
; Set the File name text on the Edit field
ControlSetText("另存为", "", "Edit1", "d:\autoit-v3-setup")
Sleep(2000)
; Click on the Open button
ControlClick("另存为", "","Button1");
相关文章推荐
- 如何重装TCP/IP协议
- Windows 8 官方高清壁纸欣赏与下载
- 谁是桌面王者?Win PK Linux三大镇山之宝
- 对《大家都在点赞 Windows Terminal,我决定给你泼一盆冷水》一文的商榷
- Windows Clang开发环境备忘
- 从Windows系统下访问Linux分区相关软件
- 对《大家都在点赞 Windows Terminal,我决定给你泼一盆冷水》一文的商榷
- Windows下搭建本地SVN服务器
- 使用Windows原生命令一键清空剪贴板
- 利用开源软件打造自己的全功能远程工具
- Windows 8虚拟机不能全屏的解决方法
- Visual Studio 2012 示例代码浏览器 - 数以千计的开发示例近在手边,唾手可得
- Visual Studio 2012 示例代码浏览器 - 数以千计的开发示例近在手边,唾手可得
- 微软镜像下载
- windows server域用户提升到本地更高权限组中的方法
- 使用命令修改注册表键值及权限
- 通过手机、电脑远程开关机,Windows和linux机手机,电脑相互控制