我正在尝试使用AutoIT上传文件。 Windows弹出窗口已打开,但文件尚未上传。不知道我在这里做错了什么
AutoIT脚本:
Local $UploadWindow
Local $Firefox
Local $Chrome
Local $IE
Local $path = $CmdLine[1]
Local $browser = $CmdLine[2]
If $browser = "Firefox" then
$Firefox = WinWait("File upload", "", 5)
ElseIf $browser = "Chrome" then
$Chrome = WinWait("Open", "", 5)
ElseIf $browser = "IE" then
$IE = WinWait("Choose File to Upload", "", 5)
EndIf
If WinExists($Firefox) then
$UploadWindow = "File upload"
ElseIf WinExists($Chrome) then
$UploadWindow = "Open"
ElseIf WinExists($IE) then
$UploadWindow = "Choose File to Upload"
Else
$UploadWindow = ""
EndIf
If $UploadWindow <> "" then
ControlFocus($UploadWindow,"","Edit1")
ControlsetText($UploadWindow,"","Edit1",$path)
ControlClick($UploadWindow,"","Button1")
EndIf
的JavaScript
public void fileUpload(){
Runtime.getRuntime().exec(.exe file path + " " + .jpg image file path + getParams.getEnvPerValue("BROWSER_TYPE"));
}
getParams.getEnvPerValue("BROWSER_TYPE")) //This will read from the Properties file.
BROWSER_TYPE = Chrome //or IE or Firefox
注意:文件上传按钮不显示<input>
标记。实际上,文件上传按钮是自定义的。所以我无法使用sendkeys()
方法
Fileupload using Sendkeys() method
非常感谢任何帮助。