2

How to capture response time of home page after login..(home page is different obviously)

Many articles told to wait until till you find specific element which is not possible in my case. Other way is sleep for some time which I am doing now.. can you please let me know any effective approach to know the load time of home page which contains multiple ajax calls.

Thanks in advance.

1 Answers1

1

Here’s a basic script which will fetch the page and calculate two timings. The back-end performance which is from when the user starts the navigation to when the first response starts. The second timing,is front-end performance, which is from when the user starts receiving the first response until the DOM is complete.

"""
Use Selenium to Measure Web Timing
Performance Timing Events flow
navigationStart -> redirectStart -> redirectEnd -> fetchStart -> domainLookupStart -> domainLookupEnd
-> connectStart -> connectEnd -> requestStart -> responseStart -> responseEnd
-> domLoading -> domInteractive -> domContentLoaded -> domComplete -> loadEventStart -> loadEventEnd
"""

from selenium import webdriver

source = "" #URL
driver = webdriver.Chrome()
driver.get(source)

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 = responseStart - navigationStart
frontendPerformance = domComplete - responseStart

print "Back End: %s" % backendPerformance
print "Front End: %s" % frontendPerformance

driver.quit()

Credit for this goes to the respective owner, taken from here

Using the above code you can execute your script between login and the homepage. You will then be able to obtain the RESPONSETIME which is simply the backendPerformance

AzyCrw4282
  • 7,222
  • 5
  • 19
  • 35