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