How to measure page load time of a website using Selenium-Python?

How to measure page load time of a website using Selenium-Python?

Hi Tom Dale,

To measure page load time of a website using Selenium-Python, use the below command:

driver = webdriver.Chrome()
driver.get(hyperlink)
 
navigationStart = driver.execute_script("return window.performance.timing.navigationStart")
responseStart = driver.execute_script("return window.performance.timing.responseStart")
domComplete = driver.execute_script("return window.performance.timing.domComplete")

backendPerformance_calc = responseStart - navigationStart
frontendPerformance_calc = domComplete - responseStart
 
print("Back End: %s" % backendPerformance_calc)
print("Front End: %s" % frontendPerformance_calc)
 
driver.quit()