Using Selenium to Check Website Speed

I use Selenium to create something like: tools.pingdom.com

This is my code:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

caps = DesiredCapabilities.CHROME
caps['loggingPrefs'] = {'performance': 'ALL'}
driver = webdriver.Chrome(desired_capabilities=caps)

driver.get('https://stackoverflow.com')

logs = [json.loads(log['message'])['message'] for log in driver.get_log('performance')]

with open('devtools.json', 'wb') as f:
    json.dump(logs, f)

driver.close()

I would like to ask you guys if using Selenium is the best approach for conducting a performance test on a website.

+4
source share

Source: https://habr.com/ru/post/1688438/


All Articles