I am executing script using Selenium Webdriver to download a file. My code is-:
package AllScripts;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.firefox.*;
import org.testng.annotations.*;
public class FileDownload_AutoIT {
WebDriver driver;
@BeforeMethod
public void init()
{
System.setProperty("webdriver.gecko.driver", "C://Selenium driver/geckodriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(3,TimeUnit.MINUTES);
}
@AfterMethod
public void stop()
{
driver.quit();
}
@Test
public void testDownload() throws InterruptedException, IOException
{
driver.get("
http://seleniumhq.org/download/");
driver.findElement(By.linkText("3.3.1")).click();
Thread.sleep(1000);
new ProcessBuilder("E:\\FDownload.exe").start();
Thread.sleep(8000);
}
}
The error that I get is
SEVERE: Unable to kill process with PID 3100
[Utils] Attempting to create E:\Sandeep\EclipseWorkspace\ExampleProject\test-output\Default suite\Default test.html
[Utils] Directory E:\Sandeep\EclipseWorkspace\ExampleProject\test-output\Default suite exists: true
[Utils] Attempting to create E:\Sandeep\EclipseWorkspace\ExampleProject\test-output\Default suite\Default test.xml
[Utils] Directory E:\Sandeep\EclipseWorkspace\ExampleProject\test-output\Default suite exists: true
FAILED: testDownload
java.io.IOException: Cannot run program "E:\FDownload.exe": CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at AllScripts.FileDownload_AutoIT.testDownload(FileDownload_AutoIT.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:646)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:823)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1131)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:778)
at org.testng.TestRunner.run(TestRunner.java:632)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:366)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319)
at org.testng.SuiteRunner.run(SuiteRunner.java:268)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1225)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1150)
at org.testng.TestNG.runSuites(TestNG.java:1075)
at org.testng.TestNG.run(TestNG.java:1047)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:126)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
at java.lang.ProcessImpl.start(ProcessImpl.java:137)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 26 more