Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium webdriver 尝试使用AutoIT和Selenium上载文件时出现“找不到文件”错误_Selenium Webdriver_Autoit - Fatal编程技术网

Selenium webdriver 尝试使用AutoIT和Selenium上载文件时出现“找不到文件”错误

Selenium webdriver 尝试使用AutoIT和Selenium上载文件时出现“找不到文件”错误,selenium-webdriver,autoit,Selenium Webdriver,Autoit,当我试图运行AutoIT.exe脚本或Selenium脚本时,它抛出了“未找到文件错误”。请建议 Selenium代码片段:=========================================================================== public static void main(String[] args) throws Exception { System.setProperty("webdriver.chrome.driver", "C:\\Use

当我试图运行AutoIT.exe脚本或Selenium脚本时,它抛出了
“未找到文件错误”
。请建议

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(); } 
ControlFocus("Open","","Edit1") 
ControlSetText("Open","","Edit1",$CmdLine[0]) 
ControlSetText("Open","","Edit1",$CmdLine[1]) 
ControlSetText("Open","","Edit1",$CmdLine[2]) 
ControlClick("Open","","Button1")
自动IT代码段:===========================================================================

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(); } 
ControlFocus("Open","","Edit1") 
ControlSetText("Open","","Edit1",$CmdLine[0]) 
ControlSetText("Open","","Edit1",$CmdLine[1]) 
ControlSetText("Open","","Edit1",$CmdLine[2]) 
ControlClick("Open","","Button1")

浏览器文件对话框窗口是否处于活动状态?如果不是自动,脚本将在窗口中输入值,以活动的为准。是否确保文件对话框处于活动状态?。一旦浏览器启动,一定要与之交互。还有一件事,如果您输入的类型是file,那么您可以使用send键而不是auto-it来输入值。

请查看您缺少详细的错误描述<代码>'File Not found error'显然告诉您任何脚本都找不到文件。您必须检查路径并确保文件存在。因为我们不知道哪个脚本和哪一行抛出了错误,所以我们无能为力编辑:如果你告诉我们你想做什么,人们可能会得到比远程点击更好的解决方案。。