0

I'm using Selenium and as part of loading a web page, a number of additional HTTP requests are made, including downloading a file of JSON encoded data which is used as data for the web page.

From within the developer tools in Chrome, I can see the name of this file, but how can I get hold of this information via Selenium?

Note that I don't know how this file is downloaded (Javascript? Something else?) and I don't really care - the data is all I care about and the file seems to have a sufficiently obvious name (but probably not fixed!) that given a list of sdownloaded files, I can figure out which one is the one I want.

Paul D Smith
  • 639
  • 5
  • 16

1 Answers1

2

Seems my question is a duplicate and the answer can be found here:

how to access Network panel on google chrome developer tools with selenium?

The key command is:

timings = driver.execute_script("return window.performance.getEntries();")

...but you want to place this in a loop in case your code makes the request too soon and the file you want has not yet been read. I used a 1s delay and a max of 20 attempts - normally takes 2 cycles for the file I want to appear in this list.

Paul D Smith
  • 639
  • 5
  • 16