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.ie.InternetExplorerDriver;
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(“webdriver.chrome.driver”, “Path\\chromedriver.exe”);
//System.setProperty(“webdriver.gecko.driver”, “Path\\geckodriver.exe”);
System.setProperty(“webdriver.ie.driver”, “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();
driver.manage().window().maximize();
//Thread.sleep(5000);
driver.get(“URL”);
Thread.sleep(5000);
//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);
System.out.println(driver.getTitle());
driver.navigate().to(“URL”);
WebElement element = driver.findElement(By.xpath(“//input[@name=’q’]”));
element.sendKeys(“Cheese”);

plugin.record();
element.submit();
controller.wait_(plugin, -1);
plugin.stop();

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());

plugin.log().save(“D:\\Test.hwl”);

driver.quit();

}
}

Download sample project with HTTP-Watch integration.
HTTPSelenium

Keep Automating!!!

No Comments

Leave a Reply

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

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, …

Shares