1

right now I am working on one project "get the response time when open a dynamic web page by using python". The requirement is that I cannot use selenium.

The web page I open has lots of javascripts and AJAX calls. So right now I use ghost.py to load the whole page. However, ghost.py takes a long time to open this web page which is much longer than opening this page on some browsers. So do you guys have any ideas or suggestions for it?

Thank you!

  • Can you give the url of your test page? Does it already use Google's defer script (http://www.feedthebot.com/pagespeed/defer-loading-javascript.html)? – Hugh Bothwell Mar 05 '14 at 01:01
  • Sorry, it's just a webpage in localhost. I don't think it use Google's defer script. – user3381397 Mar 05 '14 at 01:13
  • why can't you use selenium? If you want to measure page loading time, including the time that the scripts execute and AJAX calls, you can't avoid using a real browser. If all you need is a download time, without AJAX and scripts, then you can just urllib.urlopen the page. – Lie Ryan Mar 05 '14 at 09:26
  • Hi @LieRyan, the thing is that we already have the automation tools for testing our website, so my boss just want to me test on the backend. Yesterday, I found another library called phantomjs in python. I can load the whole page, however the time it takes to load whole page is three times slower than we open in real browser. Do you know the reason? – user3381397 Mar 05 '14 at 17:33
  • @user3381397: are you loading just the single html page or are you loading the dependant resources as well? Browsers caches aggresively and often don't actually reload most of the dependant resources (it can even avoid downloading at first page load for resources hosted on an aggressively cached CDN); also browsers loads the dependant resources in parallel. Also, are you counting the actual load time or the perceived load time? Browsers can often display pages before most of the dependant resources are loaded. Hard to tell without seeing the code you used to compare the two. – Lie Ryan Mar 05 '14 at 18:37
  • @LieRyan, I found the way. selenium + phantomjs in python. You're right. If we want to count the actual response time, we need to use a real browser. Thank you – user3381397 Mar 05 '14 at 22:11

0 Answers0