2014-01-29 60 views
0

之前,我是新的這個AutoIT,我不熟悉這一點,只是谷歌和需要完成我的任務,如果我的AtotoIt的任何錯誤,請糾正它保存對話框不能互動 - Selenium Webdriver與Java

範圍: 從IE中的Xml下載(9版),它會打開在「你想打開或保存對話框」所以我要點擊Save按鈕保存在默認的臨時文件夾中的XML文件 enter image description here

我的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

獲得爲什麼不使用wget? – Xenobiologist

回答

0
#include <_XMLDomWrapper.au3> 
#include <File.au3> 

Global $oXML = ObjCreate("Microsoft.XMLHTTP") 
$oXML.Open("GET", "YOUR URL LIKE: http://www.google.com", 0) 
$oXML.Send 

Global $sFile = _TempFile(@TempDir, '~', '.xml') 
FileWrite($sFile, $oXML.responseText) 
請問

這對你的工作?該XMLDomWrapper.au3可以從HERE

Source