2017-05-23 52 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

浏览器文件对话框活动窗口?如果不是自动,脚本将在窗口中输入值,无论哪一个是活动的。确保文件对话框有效吗?一旦启动,就与浏览器进行交互。还有一件事,如果你输入类型是文件,那么你可以使用发送键而不是自动输入值。

相关问题