HTTP Watch and selenium integration-

Process automation reduces the time and increases accuracy as well gives ample time to invest energy and efforts in other areas of the project.

In this blog post, I will be talking about IT process automation, I will be doing an integration of sniffing tool and test automation tool.

Output of code used below will bring performance statistics for single user which will be captured during test automation

What is a network sniffing tool –

A-Network sniffing tools tracks and logs the data which is being transferred during a web transaction.
Which automation testing tool we will be using for integration.

A-We will be using selenium which is an open source solution for integration with HTTP Watch.
Statistics which will be monitored/captured using Http class libraries.

1. Summary Time
2. Total time to load page(secs)
3. Number of bytes received on the network
4. HTTP compression saving(bytes)
5. Number of round trips
6. Number of errors

How we will integrate it-

Convert the Https installed files(dll) using com4j and use the generated jars in your selenium project.

Find below code snippet for a sample web transaction.

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.httpwatch.ClassFactory;
import com.httpwatch.IController;
import com.httpwatch.Plugin;
import com.httpwatch.Summary;

public class Selenium_HTTPWatch_Integration
public static void main(String [] args) throws InterruptedException
//System.setProperty(“”, “Path\\chromedriver.exe”);
//System.setProperty(“webdriver.gecko.driver”, “Path\\geckodriver.exe”);
System.setProperty(“”, “Path\\IEDriverServer.exe”);
//WebDriver driver=new FirefoxDriver();
//WebDriver driver=new ChromeDriver();
DesiredCapabilities caps=DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
caps.setCapability(“initialBrowserUrl”, “URL”);
WebDriver driver= new InternetExplorerDriver(caps);
//caps.setCapability(“initialBrowserUrl”, “URL”);
IController controller=ClassFactory.createController();
//WebElement titleElem = driver.findElement(By.xpath(“/html/head/title”));
/*System.out.println(” by xpath: ” + titleElem.getText());*/

System.out.println(“Page title is: “+driver.getTitle());

String title=driver.getTitle();
Plugin plugin=controller.attachByTitle(title);
WebElement element = driver.findElement(By.xpath(“//input[@name=’q’]”));

controller.wait_(plugin, -1);

Summary summary=plugin.log().pages(0).entries().summary();

System.out.println(” Summary Time: “+summary.time());
System.out.println(” Total time to load page(secs): “+summary.time());
System.out.println(” Number of bytes recieved on the network: “+summary.bytesReceived());
System.out.println(” HTTP compression saving(bytes): “+summary.compressionSavedBytes());
System.out.println(” Number of round trips: “+summary.roundTrips());
System.out.println(” Number of errors: “+ summary.errors().count());

System.out.println(” Page title is : “+driver.getTitle());




Download sample project with HTTP-Watch integration.


Keep Automating!!!