1

Using Karate FE tests I would like to know, if there is some way how to test file download. I understand that it is not possible to check the downloaded file, but if there is way to use and check if some file is behind the link. The FE link is simple like this:

<a href="#">Download ZIP file</a>

After clicking, the browser starts the downloading the file immediately.

Is there any possibility to check e.g. the file is there and the downloading began?

Or is there some other possibility to check file downloading using Karate?

Thank you for some advice!

Radim Bukovský
  • 337
  • 2
  • 11

1 Answers1

0

Since Karate is an API testing tool, you can download and validate files: https://stackoverflow.com/a/53706294/143475

So if you know what the URL of the file is, just do that. One thing is if any cookies are required, you will need to pass them from the "browser side" to the "API side" of Karate. * cookies driver.cookies may actually work, but I haven't tried this.

You have used href="#" in your example, but I hope that the URL is something you can easily get from the HTML / element.

If not, I don't know, you may need to do some research. Maybe you can scrape it out of the HTML. Or you need to monitor the click and do some JS magic.

Finally let me say that perhaps you should just ignore this in your test-flow. The risk of not testing this may be low and the effort of testing this may be too high to be worth it.

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248