Łukasz
Łukasz

Reputation: 2171

Verifying downloading file address

Let's assume that we have button and clicking on it triggers downloading xls document:

function download() {
  window.open("http://opendatakit.org/wp-content/uploads/static/sample.xls")
}
<input value="Download" type="button" onclick="download()">

See how it works here: location seems to change for a moment and document is being downloaded.

Let's assume that we want to write Selenium tests for that code.

Question: How can I verify (i.e. with js) if clicking on button triggers downloading file from proper address?

I tried to find some trace of change of location in window.history (window.history(-1), window.history(1)), but it seems that this change is not noticed.

Edit: I don't want to verify file content. I wan't to verify if file is downloaded from proper URL. I don't want to test service that prepares and provides file.

Upvotes: 0

Views: 210

Answers (1)

Aman B
Aman B

Reputation: 2398

If you are using the chrome web driver, you can open the downloads tab using "chrome://downloads/". You can get the download link

Upvotes: 1

Related Questions