Assuming you are using the Selenium driver, you could click the link and $this->getSession()->wait(30) until the download is complete, and then check the Files folder for the file.
That would be the easiest solution. Alternatively, you can use a proxy server, such as BrowserMob , to view all requests, and then check the response code. But that would be a very painful way for that.
The easiest way to check the file upload is to define another step with a basic statement.
public function assertFileDownloaded($filename) { if (!file_exists('/download/dir/' . $filename)) { throw new Exception(); } }
This can be problematic in situations where you download a file with the same name and the browser saves it under a different name. As a solution, you can add the @BeforeScenario hook to clear the list of knowledge files.
Another problem will be the boot disk itself - it may be different for other users / machines. To fix this, you can pass the loading directory to behat.yml as an argument to the context constructor, read the docs for this.
But the best option would be to pass the configuration to Selenium, specifying a loadable directory so that it is always clear, and you know exactly where to look. I'm not sure how to do this, but from a quick googling it seems possible.
source share