Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Last active November 23, 2020 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nolanlawson/01e7358f682dde01e9cb27f777acf195 to your computer and use it in GitHub Desktop.
Save nolanlawson/01e7358f682dde01e9cb27f777acf195 to your computer and use it in GitHub Desktop.
Test chromedriver heap snapshot

test-chromedriver

Usage

  1. Download chromedriver, extract the binary as chromedriver to the current directory
  2. Run pip install -r requirements.txt
  3. Run python test.py
  4. Try to load the snap.heapsnapshot file into Chrome Dev Tool's Memory tool (Memory -> Load)
selenium==3.141.0
import time
from selenium import webdriver
import json
service = webdriver.chrome.service.Service('./chromedriver')
service.start()
driver = webdriver.Remote(service.service_url, {})
driver.get('http://example.com');
time.sleep(2)
res = driver.execute_script(':takeHeapSnapshot')
fileout = open('snap.heapsnapshot', 'wb')
fileout.write(json.dumps(res))
driver.quit()
@tomashanecak
Copy link

Is there a way to also :ClassFilter heap snapshot and save only filtered object in json format?....Where can I find the list of all available execute_script commands? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment