w3c / webdriver-bidi

Bidirectional WebDriver protocol for browser automation
https://w3c.github.io/webdriver-bidi/
353 stars 39 forks source link

webdriver-bidi should let users know when a download is completed #427

Open asolntsev opened 1 year ago

asolntsev commented 1 year ago

Use case:

I need to write an automated test that downloads a file. My test looks like this:

  1. Click a button
  2. Wait until a download is started
  3. Wait until a download is completed
  4. Verify name and content of the downloaded file

Information from BiDi

So, the information we need from BiDi:

  1. Name and content of the downloaded file
  2. Signal (event) when the download is fully completed.

Nuances

Please take into account the following nuances:

  1. After the click, multiple files may be downloaded (we need to get info for all them!)
  2. Some downloads may last for quite a long time (say, few minutes)
  3. Some downloaded files may be quite large (say, 4 gb)
  4. Some downloads may start with a delay (say, few seconds after the click)
  5. The file may change its name during the download (the typical flow in Chrome: it first creates a file called .crdownload and later renames it to its final name when the download is completed).
karanjeetbirdeye commented 1 year ago

I was looking for something similar regarding file downloads, until this is implemented, I was thinking of capturing a particular request (the api which is pending for file download) from the network tab and waiting until it is not in pending state. However, I'm not able to find any documenation/examples that shows how to capture response or status code of a particular api call. Any help is appreciated. I'm using selenium 4.9.0 with java.

asolntsev commented 1 year ago

@karanjeetbirdeye I also wanted to do this, but didn't find this request in network tab. It seems that browser uses some different mechanism for downloading files.

ksingha161 commented 1 year ago

@asolntsev I dont think they have a particular api that tell us file downloaded is completed. In my case we have our internal api's in pending state until file download is complete. status changes to 200 when it is done. Maybe they can provide us a way to access one particular network call (whatever api we want)? then we can check if our file is downloaded or not

asolntsev commented 1 year ago

@ksingha161 That's what we are talking about. We want Bidi to give us access to file downloads. Yes, they currently have such an API, and we want to get such an API.