之前,我是这个AutoIT的新手,我不熟悉这个,只是谷歌并需要完成我的任务,如果我的AtotoIt有任何错误请更正
范围: 在从IE(版本9)下载Xml期间,它将打开“你想打开还是保存对话框”,所以我想点击保存按钮将该xml文件保存在默认的临时文件夹中
我的autoIT代码(来自http://qtp-help.blogspot.in/2009/07/selenium-handle-dialogs.html#handle_save_dialog的参考)
AutoItSetOption("WinTitleMatchMode","2") ; set the select mode to select using substring
if $CmdLine[0] < 2 then
; Arguments are not enough
msgbox(0,"Error","Supply all the arguments, Dialog title,Run/Save/Cancel and Path to save(optional)")
Exit
EndIf
; wait Until dialog box appears
WinWait($CmdLine[1]) ; match the window with substring
$title = WinGetTitle($CmdLine[1]) ; retrives whole window title
WinActivate($title)
If (StringCompare($CmdLine[2],"Open",0) = 0) Then
WinActivate($title)
ControlClick($title,"","Button1")
EndIf
If (StringCompare($CmdLine[2],"Save",0) = 0) Then
WinWaitActive($title)
ControlClick($title,"","Button2")
; Wait for the new dialogbox to open
EndIf
If (StringCompare($CmdLine[2],"Cancel",0) = 0) Then
WinWaitActive($title)
ControlClick($title,"","Button3")
EndIf
我的java代码
WebElement downloadLink = driver.findElement(By
.xpath("(//img[@alt='Download'])[3]"));
downloadLink.click();
Thread.sleep(4000);
dialog = new String[] {
"C:\\Users\\Prabakar\\Desktop\\Save_Dialog_IE.exe", "Save" };
Runtime.getRuntime().exec(dialog);
请帮忙解决
答案 0 :(得分:0)
在不使用AutoIT的情况下,查看下载文件的其他方法。
答案 1 :(得分:0)