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.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 *

Automation
Triggering SoapUI from selenium

The software industry has adopted Service Oriented Architecture-SOA, which consist of Microservices consist of SOAP and REST. Selenium is an API which helps in Web automation, Selenium does not help in API testing although SoapUI scripts can be invoked from selenium/Java classes. Using below 3 steps SOAPUI project can be …

Selenium Basic
1
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
1
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- …

Shares