Open robingustafsson opened 3 years ago
Unlike browser downloads (#98), which happen entirely on the browser side AFAIU, this would return the PDF data to the JS script, right? From there the user could upload the file somewhere or inspect it directly, but k6 can't write it to the filesystem, unless we use something like xk6-file, which would run into issues with more than one VU. I guess we could template the filename per VU, or something like that.
How do you envision this working @robingustafsson?
Yes, it would be returned to the JS script (see Page.printToPDF()).
The user should be able to specify a path
option to save the file to the filesystem, same as with Page.screenshot()
and ElementHandle.screenshot()
. This raises issues with disk writes while running the test, yes. We'll need to find a solution that would both work for the single VU functional test use case where writing to disk makes sense (but perhaps async off-thread) as well as when running in a load test with many VUs where writing directly to disk for every VU doesn't make as much sense.
Same situation for video capture in https://github.com/grafana/xk6-browser/issues/103.
Let's start with the use cases as I seem them:
expect(screenshot).toMatchSnapshot(filename)
.I don't have a ready solution how to implement this in terms of APIs/options right now :sweat_smile: but I'm confident we can come up with something that will work.
Perhaps @nicolevanderhoeven and @tom-miseur can fill in with more use cases for screenshots, videos, PDFs and downloads.
+1 to everything Robin said. Some other use cases I can think of:
Add support for
Page.pdf([options])
, to saving a page down to a PDF file.Relevant links:
Page.pdf([options])
: https://github.com/grafana/xk6-browser/blob/main/common/page.go#L504