wardaddy
wardaddy

Reputation: 443

How to verify file download on docker containers without volumes?

I am trying to set up an automation test suit using selenium-grid,docker containers, jenkins and aws-ecs.

The selenium-grid will be setup using aws-ecs. The automation tests will be executed as part of a jenkins pipeline.

The problem is that the test suite contains file download tests. I can not use volumes since the containers will be spun up on a different machine than the jenkins workspace.

Is there any way I can assert that a file has downloaded? Can a browser instance running in the container provide any confirmation that the file download has started?

Please find below the stepdef I used for verifying file download on a local setup.

@And("a file called (.*) should be downloaded to my downloads directory")
public void verifyFileDownload(String filename) throws InterruptedException {
    Thread.sleep(1000);
    List<String> results = new ArrayList<String>();
    File[] files = new File(DOWNLOAD_DIRECTORY).listFiles();
    for (File file : files) {
        if (file.isFile()) {
            results.add(file.getName());
        }
    }
    assertThat(results.contains(filename), is(true));
}

Upvotes: 0

Views: 1782

Answers (1)

Kilian
Kilian

Reputation: 1781

You can go inside your container. If you know on which server run your container is runnning, you can run

docker exec -it [container_name] /bin/bash

And check manually if your file is here.

Upvotes: 2

Related Questions