blueprintmrk / selenium-vba

Automatically exported from code.google.com/p/selenium-vba
0 stars 0 forks source link

I would like to use Firebug or Httpfox plugin to get request Send, Wait, Recieve timings #46

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Operating system : Win7, Browser: Firefox 26
.Net Framework version :
Office Version : 2010
SeleniumWrapper version : v1.0.17.0 

What is your issue ?

Original issue reported on code.google.com by anotherk...@gmail.com on 25 Jan 2014 at 12:55

GoogleCodeExporter commented 9 years ago
Run "firefox -p" and create the profile "Selenium" for example, launch it and 
install your extensions.
Then to use it in a script:
Dim driver As New SeleniumWrapper.WebDriver
driver.setProfile "Selenium"
driver.start "firefox", "http://www.google.com"

Original comment by florentbr on 25 Jan 2014 at 1:18

GoogleCodeExporter commented 9 years ago
Thank you for quick response.

I followed exactly what was mentioned above and I was able to run my tests with 
firefox profile which has extensions installed. I would like automate Firebug 
or Httpfox to get request timings. For example:

Set selenium = New SeleniumWrapper.WebDriver

  selenium.setProfile "Automated"
  selenium.start "Firefox", "http://www.google.com"
  selenium.Open "/"

  selenium.type "id=gbqfq", "Performance Testing with Selenium and firebug"
  selenium.click "id=gbqfb"

At this point I would like to get 'Wait' time (time spent waiting for a 
response message from the server) for page to load and display results.

I can manually start firebug and get timings but when executing automated test 
cases I would like to automate this process also and gather performance data 
from the plugin.

I can also use Httpwatch for firefox and there are examples with httpwatch but 
in VB.Net. 

https://blog.httpwatch.com/2008/07/23/automating-httpwatch-with-visual-basic/

Thanks in advance.

Original comment by anotherk...@gmail.com on 25 Jan 2014 at 2:17

Attachments:

GoogleCodeExporter commented 9 years ago
I'm not aware of any way to interact with a Firefox extension using the 
Selenium framework.
Another possibility would be to automatically save the performance data in a 
folder while the automation is running.
If found it can be done with Firebug and NetExport:
http://www.softwareishard.com/blog/firebug/automate-page-load-performance-testin
g-with-firebug-and-selenium/
But then you'll still have to create a parser extract the metrics you need from 
the generated .har files.

If what you're just trying to achieve is just to measure the time to load a 
page, I suggest you to measure the elapsed time after each command and save the 
result in a worksheet.

Let me know if you find a solution to automate it.

Original comment by florentbr on 25 Jan 2014 at 5:44

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I found another way. There's a JavaScript function to measure web page loading 
speed.
Try this command in a Firefox console : window.performance.timing;

Here is the way to get the "Page loading", "Server waiting", "Server receiving" 
and "DOM loading" time with selenium :

Set times = driver.executeScript("var t=window.performance.timing; return 
[t.loadEventEnd-t.navigationStart,t.responseStart-t.requestStart,t.responseEnd-t
.responseStart,t.domComplete-t.domLoading];")

And a full example with Excel which writes the times in a worksheet :

Public Sub PrintLoadingTimes(driver As SeleniumWrapper.WebDriver)
    Static i As Integer
    If i = 0 Then Sheet1.Range("A1:E1") = Array("Page Url", "Page loading", "Server waiting", "Server receiving", "DOM loading")
    i = i + IIf(i = 0, 2, 1)
    Sheet1.Cells(i, 1) = driver.URL
    Sheet1.Range("B:E").Rows(i) = Split(driver.executeScript("var t=window.performance.timing; return [t.loadEventEnd-t.navigationStart,t.responseStart-t.requestStart,t.responseEnd-t.responseStart,t.domComplete-t.domLoading].join(' ');"), " ")
End Sub

Public Sub extractdata()
    Dim driver As New SeleniumWrapper.WebDriver
    driver.Start "ff", "http://uk.news.yahoo.com"

    driver.Open "/finance"
    PrintLoadingTimes driver

    driver.Open "world"
    PrintLoadingTimes driver

    driver.Open "/opinion"
    PrintLoadingTimes driver

    driver.Open "/business"
    PrintLoadingTimes driver

    driver.stop
End Sub

I may include a new command to get those metrics in the next release.

Original comment by florentbr on 25 Jan 2014 at 9:20

GoogleCodeExporter commented 9 years ago
Perfect! Works like a charm.

Selenium VBA Wrapper is very helpful, thanks again for all your hard work it is 
much appreciated.

Original comment by anotherk...@gmail.com on 25 Jan 2014 at 11:32

GoogleCodeExporter commented 9 years ago

Original comment by florentbr on 8 Sep 2014 at 5:40