I am trying to get the page load times using python & selenium by executing javascript command performanance.timing
I am able to get the values properly when Navigate to another page but If I am doing a trnasaction/action from the same page whch will take me to another tab in the same page, the performanance.timing does not change.
Note: I am able to get the values changed if I reload the page
Can someone advise me on how I will get the load times of each step I do in my web app.
python selenium script:
from selenium import webdriver
driver = webdriver.Firefox()
driver.implicitly_wait(40)
########### Home Page #################
driver.get("http://app.edulastic.com")
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")
loadStart = driver.execute_script("return window.performance.timing.domInteractive")
loadend = driver.execute_script("return window.performance.timing.navigationStart")
backendPerformance = responseStart - navigationStart
frontendPerformance = domComplete - responseStart
loadingTime=loadStart-loadend
print ("Back End Homepage: %s" % backendPerformance)
print ("Front End Homepage: %s" % frontendPerformance)
print("loading time : %s" %loadingTime)
#################### Dashboard ##################
driver.find_element_by_id('login-email').send_keys("*****@gmail.com")
driver.find_element_by_id("login-password").send_keys("******")
driver.find_element_by_id("signIn").click()
driver.find_element_by_link_text("Create New Assignment")
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")
domLoading = driver.execute_script("return window.performance.timing.domLoading")
loadStart = driver.execute_script("return window.performance.timing.domInteractive")
loadend = driver.execute_script("return window.performance.timing.navigationStart")
backendPerformance = responseStart - navigationStart
frontendPerformance = domComplete - responseStart
loadingTime=loadStart-loadend
#print("time converted ... %s" %time.strftime("%SSSS", time.gmtime(domLoading)))
print ("Back End Dashboard: %s" % backendPerformance)
print ("Front End Dashboard: %s" % frontendPerformance)
print("loading time : %s" %loadingTime)
#print("dom laoding time :%s" %domLoading)
########## create new assignment #########
driver.find_element_by_link_text("Create New Assignment").click()
print(driver.find_element_by_id("create-assessment-with-val").is_displayed())
loadStart = driver.execute_script("return window.performance.timing.domInteractive")
loadend = driver.execute_script("return window.performance.timing.navigationStart")
loadingTime = loadStart-loadend
print("loading time : %s" %loadingTime)
driver.quit()
create new Assignment section navigates to another tab on the side of the page but timing values doesn't change.
Image --