2017-05-23 54 views
0

當我嘗試運行AutoIT.exe腳本或我的Selenium腳本時,它會拋出'File Not found error'。請建議!當試圖使用AutoIT和Selenium上傳文件時找不到文件錯誤

硒的代碼片段:===================================

public static void main(String[] args) throws Exception { System.setProperty("webdriver.chrome.driver", "C:\\Users\\IBM_ADMIN\\Desktop\\Drivers\\chromedriver.exe"); 

WebDriver driver = new ChromeDriver(); 
driver.get("http://demo.automationtesting.in/Register.html"); 
driver.manage().window().maximize(); Thread.sleep(2000); 
driver.findElement(By.xpath("//input[@id='imagesrc' and @type='file']")).click(); 
Runtime.getRuntime().exec("C:\\Users\\IBM_ADMIN\\Desktop\\Selenium practise\\SeleniumAssignment\\AutoIT\\MultipleFileUpload.exe"+" "+"C:\\Users\\IBM_ADMIN\\Desktop\\0234_005.pdf"); Thread.sleep(2000); 
driver.findElement(By.xpath("//input[@id='imagesrc' and @type='file']")).click(); 
Runtime.getRuntime().exec("C:\\Users\\IBM_ADMIN\\Desktop\\Selenium practise\\SeleniumAssignment\\AutoIT\\MultipleFileUpload.exe"+" "+"C:\\Users\\IBM_ADMIN\\Desktop\\BRP_SujataChakraborty.pdf"); driver.quit(); } 

AutoIt代碼片段:============================

ControlFocus("Open","","Edit1") 
ControlSetText("Open","","Edit1",$CmdLine[0]) 
ControlSetText("Open","","Edit1",$CmdLine[1]) 
ControlSetText("Open","","Edit1",$CmdLine[2]) 
ControlClick("Open","","Button1") 
+0

請參閱https://stackoverflow.com/help/how-to-ask – demouser123

+0

您錯過了詳細的錯誤說明。 ''文件未找到錯誤''顯而易見告訴你任何腳本都找不到文件。您必須檢查路徑並確保文件存在。由於我們不知道哪個腳本和哪一行會引發錯誤,因此我們無法提供幫助。 - **編輯:**如果您告訴我們您要做什麼,那麼人們可能會得到更好的解決方案,然後只做遠程點擊。 – Yaerox

回答

0

瀏覽器文件對話框活動窗口?如果不是自動,腳本將在窗口中輸入值,無論哪一個是活動的。確保文件對話框有效嗎?一旦啓動,就與瀏覽器進行交互。還有一件事,如果你輸入類型是文件,那麼你可以使用發送鍵而不是自動輸入值。

相關問題