IT Automation-Integration of Selenium and Sniffing tool (HttpWatch)

Test Automation

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!!!

Its Prashant Chaudhary, I have 10+ years of experience in software test automation, performance & process automation with various commercial and open source tools. This blog shares my experience on the topic of Automation. The content published on my blog is solely mine, it does not express the views of any of my employers (current or previous).
No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Selenium Basic
Step by step selenium – step 3, what is findelement method

Abstract- So far, we have learned how to launch a web browser, entering values in a text box and clicking button. In this post, we will learn about findelement method. Test automation is all about get and set, which means get from web and set into web. Talking more specifically- …

Test Automation
What is ITestListner interface and its Use in Selenium

There are several interfaces available in TestNG that allow you to modify TestNG’s behavior or to give test scripts additional strength. These interfaces are broadly called “TestNG Listeners”. Here are a few listeners which are commonly used: 1- IAnnotationTransformer 2- IAnnotationTransformer2 3- IHookable 4- IInvokedMethodListener 5- IMethodInterceptor 6- IReporter 7- …

Test Automation
How to Capture Screenshot in Selenium Webdriver-3 different ways

Abstract– Capturing screenshot is an essential feature of a test automation framework, They help in defect analyses once after test execution is over. In this blog post we will see how to capture screenshot, there are different ways to capture screenshots. Which includes- 1- Capture full Page 2- Capturng full …