Selenium+autoit+java 上传文件
来源:互联网 发布:淘宝小号信誉查询 编辑:程序博客网 时间:2024/04/30 15:26
【1】selenium: 触发点击事件打开上传控件
【2】autoit:控制windows组件【注意点:.au3文件是源文件,执行文件是exe;若在源文件界面F5运行会报错“拒绝访问”】
(http://img.blog.csdn.net/20160422145924983)
上传文件代码如下:(存放在D:\autoit\upload.exe)
;first make sure the number of arguments passed into the scripts is more than 1
IfCmdLine[0]<2ThenExitEndIf;ifparmasnum<2,thenbreak; CmdLine[0] ;参数的数量
;CmdLine[1];第一个参数(脚本名称后面); CmdLine[2] ;第二个参数
;都是从cmd传入参数
handleUpload(CmdLine[1], CmdLine[2])
;定义上传函数,有两个参数,第一个是浏览器名字,第二参数是文件路径
Func handleUpload(
Dim
$title=”文件上传”
EndIf
if WinWait($title,"",4) Then ;等待弹出出现,最大等待时间是4秒 WinActivate($title) ;找到弹出窗口之后,激活当前窗口 ControlSetText($title,"","Edit1",$uploadfile) ;把文件路径放入输入框,此”Edit1“是用FinderTool获取到的 ControlClick($title,"","Button1") ;点击保存或者打开或者上传按钮,此“Button1”使用FinderTool获取到的 Else Return False EndIf
EndFunc
【3】JAVA:调用autoit的exe文件
import java.io.File;
public class base {
static void publicvoidhandleUpload(String browser, String str) { File file = new File(str); String filePath= file.getAbsolutePath(); String executeFile= "D:\\autoit\\upload.exe"; //定义了upload.exe文件的路径 String cmd= "\""+ executeFile+ "\""+ " "+ "\""+ browser+ "\""+ " "+ "\""+ filePath+ "\""; try{ Process p= Runtime.getRuntime().exec(cmd); p.waitFor(); } catch(Exception e) { e.printStackTrace(); }}
- Selenium+autoit+java 上传文件
- selenium借用AutoIt 实现上传文件
- selenium借用AutoIt 实现上传文件
- python+selenium+autoit实现文件上传
- 利用Selenium实现文件上传的AutoIt介绍
- selenium借助AutoIt识别上传
- Java+Selenium3方法篇38-AutoIt工具处理文件上传
- selenium自动化测试,上传功能 之 使用 autoit工具,java语言
- AutoIT 实现Firefox上传文件
- 【WebDriver】使用AutoIt上传文件
- selenium上传附件(借助AutoIt识别Windows上传窗口)
- selenium借助AutoIt识别上传(下载)详解
- selenium借助AutoIt识别上传(下载)详解
- selenium借助AutoIt识别上传(下载)详解
- (4)selenium常见问题-Autoit实现上传附件
- 使用autoit解决webdriver文件上传问题
- WebDriver 与Autoit结合完成文件上传
- 使用第三方工具AutoIt上传文件
- 非静态成员的sizeof
- win2003右键没有(共享和安全)的问题
- 分享 Matlab实现视频图像前景分割
- 深入理解Objective-C:Category(上)
- UVa 165 - Stamps
- Selenium+autoit+java 上传文件
- Android自定义控件---“取消”视图
- 客户端时间存储的取舍
- Android 绘图笔记(一)Region
- linux 环境变量设置、指令学习、日常用到的linux知识
- C++中虚析构函数的作用
- php JSON数据格式化方法
- UBI文件系统制作和挂载
- 面试频率最高的关键字——static