Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to capture all requests made by page in webdriver? Is there any alternative to Browsermob?

I am using Selenium2/WebDriver to test my web applications. All the tests are written in Java and run with Maven.

While opening a page with webdriver I'd like to capture all the requests made by page (images, js and css files, etc). I use this data mainly for two reasons

  • checking for 404 (and other errors) in calls
  • checking if analytics code is working (checking if it's sending proper requests)

Depending on the project I use either Firebug with Netexport or Browsermob proxy. In both cases I can easily obtain a HAR (Html ARchive) file, parse it and extract the data I want.

Here's the problem: I am not happy with neither of these solutions. I have especially problems with getting HAR file when a page contains video that is being loaded too long. I am looking for something more stable.

So, the questions are:

Is there any alternative to Browsermob? I know about FiddlerCore but it's a .NET library and my tests are written in Java. I've also heard about Ajax DynaTrace and I know that there is some way to integrate it with Selenium but the documentation I found was for Selenium-RC not WebDriver.

Is there any way to integrate DynaTrace with WebDriver or use FiddlerCore with Java?

Is there any other way to achieve the goals I mentioned? I am looking for a proxy that I can easily control from my code. Exporting data to HAR would be a great plus.

like image 822
JacekM Avatar asked May 25 '12 13:05

JacekM


People also ask

How can I capture network traffic of a specific page using Selenium?

We can capture network traffic on a specific page using Selenium webdriver in Python. To achieve this, we take the help of the JavaScript Executor. Selenium can execute JavaScript commands with the help of the execute_script method. JavaScript command to be executed is passed as a parameter to this method.

How does BrowserMob proxy work?

BrowserMob Proxy is an open source tools which is used to capture performance data for a web applications in an HAR format. It also allows to manipulate browser behavior and traffic, such as simulating network traffic, rewriting HTTP requests and responses etc.

Which is better Selenium or requests?

Using Requests generally results in faster and more concise code, while using Selenium makes development faster on Javascript heavy sites.

What is the get () method used for in Selenium?

The get command launches a new browser and opens the given URL in your Webdriver. It simply takes the string as your specified URL and opens it for testing purposes. If you are using Selenium IDE, it is similar to open command.


1 Answers

I found a google groups discussion on the topic. These links look like promising alternative to Browsermob:

like image 79
r-sal Avatar answered Sep 21 '22 21:09

r-sal