title: Right way to test page load time in selenium?
body: <p>I'm trying to programatically test the load time of a list of websites. The purpose is to roughly simulate the page load time a user will perceive.</p>
  
  <p>My first approach is to call the following inside a loop:</p>
  
  <pre><code>    startTime = System.currentTimeMillis();
      driver.get("http://" + url);
      diff = System.currentTimeMillis() - startTime;
      System.out.println("Load time was " + diff);
  </code></pre>
  
  <p>The problem is sometimes I get the time result before the page has really loaded (i.e i get 50ms times) so I guess the control is being handed to the next instruction before the <code>driver.get()</code> has completed.</p>
  
  <p>What should I do to improve this test?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>As user1258245 suggested I could wait for an element to load but the problem is I don't know which pages ill be loading beforehand.</p>