0

I want to get a HAR file using chrome.devtools.network.getHAR(). Specifically, I am using Selenium within a MahiMahi replay shell, and I want to inject JS that will dump the HAR into a file. The standard JS injection (Selenium's executeScript method) does not work, because the page's JS scope does not include DevTools compatibility. With this in mind, I have a series of questions:

  1. Where and how can I use methods like chrome.devtools.network.getHAR()? I have yet to find where I can run this, as the console when I F12 doesn't have it in scope.
  2. Can I automate this process?
  3. Can I get to this using Selenium specifically, or are there any other browser automation techniques that would work better? (Though I would prefer to avoid PhantomJS because it's outdated)
  4. Are there any other easier ways to automate getting a HAR file from a site?

Note: My code base is in Python

Thank you!

K. Dackow
  • 456
  • 1
  • 3
  • 15
  • 1
    That getHAR method is from chrome extensions [devtools API](https://developer.chrome.com/extensions/devtools_network) so you need an extension to run it. Or you can reimplement the entire thing using [devtools protocol](https://chromedevtools.github.io/devtools-protocol/tot/Network) which should be accessible/executable in Selenium, but I'm not an expert on this. Also, try finding an existing solution. – wOxxOm Jul 26 '18 at 15:24
  • Thanks! I've searched around for an existing solution and none seem to exist... I am presently trying to make a devtools extension for this, so any pointers for a good tutorial would be welcomed. Regarding the protocol, the getHAR method isn't documented there so I don't think I can do that, as of now. – K. Dackow Jul 26 '18 at 15:30
  • I meant you can reimplement [what getHAR does](https://cs.chromium.org/chromium/src/third_party/blink/renderer/devtools/front_end/extensions/ExtensionServer.js?q=GetHAR&l=437) by hooking the available protocol events and methods, which is basically what GetHAR does internally. – wOxxOm Jul 26 '18 at 15:47

0 Answers0