![](/img/trans.png)
[英]Multiple file upload through AutoIt using Selenium-WebDriver
[英]Upload file via window prompt in Selenium WebDriver using AutoIt
我想在Selenium WebDriver中使用AutoIt上傳文件。 我有AutoIt代碼,用於在窗口提示中粘貼文件的路徑,然后單擊打開按鈕。
但是我的問題是使用下面的代碼單擊“瀏覽”按鈕后,出現文件上傳的窗口提示,並且我的代碼沒有從該點移動到下一個我調用自動可執行文件的行。
driver.findElement(By.xpath("//div[@class='field-group file-inputlist']//div[@class='field-group ']//input")).click();
我的AutoIt代碼是
WinWait("[CLASS:#32770]","",10) ;
//Set input focus to the edit control of Upload window using the handle returned by WinWait
ControlFocus("File Upload","","Edit1") Sleep(2000) ;
//Set the File name text on the Edit field
ControlSetText("File Upload", "", "Edit1", $CmdLine[1]) Sleep(2000) ;
//Click on the Open button
ControlClick("File Upload", "","Button1");
Eclipse甚至沒有拋出任何錯誤或異常。 代碼停止在瀏覽器單擊“瀏覽”按鈕並打開窗口提示的位置。
注意:如果我手動關閉窗口提示,則代碼將從此處繼續。
文件上傳要遵循的步驟是:
嘗試步驟2-4的示例代碼
樣例代碼:
WinWait("File Upload")
WinActivate("File Upload")
ControlSetText("File Upload", "", "[CLASS:Edit;INSTANCE:1]",$CmdLine[1])
;ControlSetText("Choose", "", "[CLASS:Edit;INSTANCE:1]", "*****Absolute File Path********")
ControlClick("File Upload", "", "[CLASS:Button;TEXT:&Open]")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.