How to access Downloads folder in taiko automation

523 Views Asked by At

I want to verify whether file is downloaded or not after clicking download link. I am using taiko for automating this task. I tried to open recent downloads in browser by using these taiko commands goto("chrome://downloads/") and press(['Control','J']) but both did't work. Is there any other method to do the same task.And i want know why above commands are not working

1

There are 1 best solutions below

2
callmekatootie On BEST ANSWER

Check out this example

You need to first set the download path:

// client function is imported from taiko
await client().send('Page.setDownloadBehavior', {
  behavior: 'allow',
  downloadPath: downloadPath,
});

You then need to download your file (trigger the action that results in the file getting downloaded - the example uses a click action. And then, after a suitable time has elapsed, you will check the download path that you registered earlier for existence of the file:

expect(path.join(downloadPath, 'foo.txt')).to.exist;