title: How to download a file using Selenium WebDriver (Java) integrated with wget
body: <p>I'm trying to download a file using WebDriver and wget. I'm getting exit value 0 but download is not happening. My code is as below:</p>
  
  <pre><code>import java.io.IOException;
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.firefox.FirefoxDriver;
  
  public class Download {
      public static void main(String args[]) throws InterruptedException{
          FirefoxDriver driver=new FirefoxDriver();
          driver.manage().window().maximize();
          driver.get("http://www.thinkbroadband.com/download.html");
          Thread.sleep(2000);
  
          WebElement ele=driver.findElement(By.tagName("a"));
          String sourcelocation=ele.getAttribute("href");
          //     String sourcelocation="http://download.thinkbroadband.com/5MB.zip"
          //    System.out.println("downloadURL="+sourcelocation);
  
          String wget_commond = "cmd /c:/User/TestOptimizer-Raghav&gt;wget no-check-certificate " +sourcelocation;  
          System.out.println(wget_commond);
  
          try {
              Process exec = Runtime.getRuntime().exec(wget_commond);
              int exitVal = exec.waitFor();
              System.out.println("Exit value: " + exitVal);
              System.out.println("Download completed");
          } catch (IOException ex) {
              System.out.println(ex.toString());
              System.out.println("Download failed");
          } 
          driver.quit();
      }
  }
  </code></pre>