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

No Comments

Leave a Reply

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

Test Automation
3 Easy steps for Running selenium scripts in Sauce Labs

Hello Readers, Its been a long time publishing any post, I have done a small execution of selenium script in a remotely placed device on saucelabs. Below piece of code will help you in doing the same. There are 3 simple steps to connect and run your automation script in …

Test Automation
Test Automation some useful selenium hacks

Selenium Hacks- In this post I will be sharing some quick tips on selenium,Below are some of the code snippets that I mostly used when I am creating java test cases using selenium webdriver. I hope the same will help you save some time in your test script creation. These …

automation testing
Test Automation
Test Automation-Easy steps to create test-output folder Backup in TestNG automatically

Overview– TestNG is widely used and most preferred in test automation, It contains several features that are beneficial for Unit testing, regression, and Integration testing. In this article we will see out report generated by Test-NG can be copied in every run. Test-NG generate its execution report in test-output folder, …