2

I am pretty new with using python with selenium web testing.

I am creating a handful of test cases for my website and I would like to see how long it takes for specific pages to load. I was wondering if there is a way to print the page load time after or during the test.

Here is a basic example of what one of my test cases looks like:

import time
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get("some URL")

driver.implicitly_wait(10)

element = driver.find_element_by_name("username")
element.send_keys("User")
element = driver.find_element_by_name("password")
element.send_keys("Pass")
element.submit()

time.sleep(2)
driver.close()

In this example I would like to see how long it took for the page to load after submitting my log in information.

Chris
  • 123
  • 1
  • 1
  • 21
  • At least related: http://stackoverflow.com/questions/11245062/how-can-we-get-exact-time-to-load-a-page-using-selenium-webdriver and http://stackoverflow.com/questions/11360854/right-way-to-test-page-load-time-in-selenium. – alecxe Aug 04 '15 at 17:07
  • @alecxe Thanks for the references. Didn't really help me though. – Chris Aug 04 '15 at 17:33

1 Answers1

1

I have found a way around this by running my tests as python unit tests. I now record my steps using the selenium IDE and export them into a python file. I then modify the file as needed. After the test runs it shows the time by default.

Chris
  • 123
  • 1
  • 1
  • 21