@Test
 public void statusCode404FromString() throws Exception {
   FileDownloader downloadHandler = new FileDownloader(driver);
   downloadHandler.setURI(webServerURL + ":" + webServerPort + "/doesNotExist.html");
   downloadHandler.setHTTPRequestMethod(RequestMethod.GET);
   assertThat(downloadHandler.getLinkHTTPStatus(), is(equalTo(404)));
 }
 @Test
 public void statusCode200FromURL() throws Exception {
   FileDownloader downloadHandler = new FileDownloader(driver);
   downloadHandler.setURI(downloadURI200.toURL());
   downloadHandler.setHTTPRequestMethod(RequestMethod.GET);
   assertThat(downloadHandler.getLinkHTTPStatus(), is(equalTo(200)));
 }
 @Test
 public void statusCode405FromURLUsingDelete() throws Exception {
   FileDownloader downloadHandler = new FileDownloader(driver);
   downloadHandler.setURI(downloadURI200.toURL());
   downloadHandler.setHTTPRequestMethod(RequestMethod.DELETE);
   assertThat(downloadHandler.getLinkHTTPStatus(), is(equalTo(405)));
 }
 @Test
 public void statusCode404FromURLUsingHead() throws Exception {
   FileDownloader downloadHandler = new FileDownloader(driver);
   downloadHandler.setURI(downloadURI404.toURL());
   downloadHandler.setHTTPRequestMethod(RequestMethod.HEAD);
   assertThat(downloadHandler.getLinkHTTPStatus(), is(equalTo(404)));
 }
  @Test
  public void downloadAnImage() throws Exception {
    FileDownloader downloadHandler = new FileDownloader(driver);
    driver.get(webServerURL + ":" + webServerPort + "/downloadTest.html");
    WebElement image = driver.findElement(By.id("ebselenImage"));
    downloadHandler.setURISpecifiedInImageElement(image);
    File downloadedFile = downloadHandler.downloadFile();

    assertThat(downloadedFile.exists(), is(equalTo(true)));
    assertThat(downloadHandler.getLinkHTTPStatus(), is(equalTo(200)));
  }
  @Test
  public void downloadAFileWhilstMimicingSeleniumCookies() throws Exception {
    // TODO modify test page to require a cookie for download
    FileDownloader downloadHandler = new FileDownloader(driver);
    driver.get(webServerURL + ":" + webServerPort + "/downloadTest.html");
    WebElement downloadLink = driver.findElement(By.id("fileToDownload"));
    downloadHandler.setURISpecifiedInAnchorElement(downloadLink);
    downloadHandler.mimicWebDriverCookieState(true);
    File downloadedFile = downloadHandler.downloadFile();

    assertThat(downloadedFile.exists(), is(equalTo(true)));
    assertThat(downloadHandler.getLinkHTTPStatus(), is(equalTo(200)));
  }
  @Test
  public void downloadAFileFollowingRedirects() throws Exception {
    // TODO modify test page to set a redirect to file download
    FileDownloader downloadHandler = new FileDownloader(driver);
    driver.get(webServerURL + ":" + webServerPort + "/downloadTest.html");
    WebElement downloadLink = driver.findElement(By.id("fileToDownload"));
    downloadHandler.setURISpecifiedInAnchorElement(downloadLink);
    downloadHandler.followRedirectsWhenDownloading(true);
    File downloadedFile = downloadHandler.downloadFile();

    assertThat(downloadedFile.exists(), is(equalTo(true)));
    assertThat(downloadHandler.getLinkHTTPStatus(), is(equalTo(200)));
  }