Exemplo n.º 1
0
  @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)));
  }
Exemplo n.º 2
0
  @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)));
  }
Exemplo n.º 3
0
  @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)));
  }