【发布时间】:2014-01-29 07:17:52
【问题描述】:
之前,我是这个AutoIT的新手,对此我不熟悉,只是google,需要完成我的任务,如果我的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);
请帮忙解决
【问题讨论】:
标签: selenium selenium-webdriver autoit