SlideShare a Scribd company logo
Sandeep Tol
Senior Architect, Wipro
Selenium Automation with HTTPWatch Plugin
 Selenium framework allows to simulate real browser like Internet explorer,
Chrome or Firefox and automate the execution of user navigations via scripts in
the browser. There are enormous articles, tutorials available on automation with
selenium. However there is focus given for capturing web page performance
KPIs,page load times & Browser HTTP network logs during such Selenium test
runs.
 Currently there is no Java API available to interface Http Watch plug-in API.
solution given in this article show how to use HTTP Watch browser plug-in
,collect logs and measure page performance with Java .
 This document would help developers/Testers to write to use Java
programming for selenium scripts with capturing HTTP log data using
HTTPWatch plugin & capture performance KPI of pages and automate in
detection of web performance issues.
Selenium Automation with HTTPWatch Plug-in Sandeep.tol@outlook.com 2
About HTTPWatch Plug-in
 HttpWatch browser plug-in helps to measure Performance of web pages like Page
Load time, Number of Javaacript files, Number of CSS files, Number of HTTP
Errors, Number of requests etc in Internet Explorer or Firefox . HTTP Watch is
external plug-in available in Basic & professional edition for Internet explorer to
capture HTTP logs. One can also buy Professional Edition that comes with more
features for detailed analysis. Free Basic edition is enough for most of the cases!
Selenium Automation with HTTPWatch Plug-in Sandeep.tol@outlook.com 3
Java Interfacing for Http Watch Plugin
 HTTP Watch comes with inbuilt API support to integrate with selenium scripts written in C# or PHP
scripts . Refer http://apihelp.httpwatch.com/#Automation%20Overview.html
 But unfortunately we don’t have API written for JAVA. The solution is to use Java COM bridge and invoke
HTTP Watch plugin API from Java selenium scripts.
Selenium Automation with HTTPWatch Plug-in Sandeep.tol@outlook.com 4
HttpWatch Plugin
-Record
-Stop
-Log
Java Selenium Code
JavaComBridge
Pages Summary
-Load Times, URL Data
- Content Sizes (CSS/JSS,IMG
sizes) , Save Log files
HWL Files
( Log files)
Java Based HttpWatch Automation with
Selenium
Controller
 Step 1 :
Download and install HTTPwatch plug-in for IE in your system. You can download here download
Ensure that latest Install JRE or JDK is available on system
 Step 2 :
Download COM Bridge https://java.net/projects/com4j/downloads and unzip files . There are few other
commercial java com bridge available. But I found the above one is good and efficient . You can also refer
to tutorial on converting various COM objects into Java interfaces here.
https://com4j.java.net/tutorial.html
 Step 3 :
Open “Command Prompt” and navigate to the folder where you have extracted Com4J files .
Copy HTTPWatchx64.dll ( for 32 bit Windows it would be httpwatch.dll) from HTTPwatch plugin
installation folder to same folder where COM4J files are extracted. On Windows the HTTPwatch would be
installed in C:Program Files (x86)HttpWatch
Selenium Automation with HTTPWatch Plug-in Sandeep.tol@outlook.com 5
 Step 4 :
Convert COM component to Java API
. Execute following command
Java – jar tlbimp.jar -o <outputFolder> –p <packagename> DLL file
Below command would generate files in “output” folder
Java – jar tlbimp.jar -o outputFolder –p com.httpwatch httpwatchx64.dll
Selenium Automation with HTTPWatch Plug-in Sandeep.tol@outlook.com 6
Generated Java Interface files
for HTTPWatch Plugin
Java Selenium Code with Http Watch Plugin
 Include the httpwatch API that was generated into your selenium project. Below is
the code used in Ecipse IDE after importing httpWatch API classes.
Selenium Automation with HTTPWatch Plug-in Sandeep.tol@outlook.com 7
Java Selenium Code with Http Watch Plugin
Selenium Automation with HTTPWatch Plug-in Sandeep.tol@outlook.com 8
public class SeleniumIEHttpwatch {
public static void main(String[] args) {
InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver = new InternetExplorerDriver(capabilitiesIE);
IController controller = ClassFactory.createController();
driver.manage().window().maximize();
// And now use this to visit Google
driver.get("http://www.google.com");
// Check the title of the page
String title = driver.getTitle();
// Creae Plugin instance
Plugin plugin = controller.attachByTitle(title);
// Do some transaction in page e.g Search
//WebElement element = driver.findElement(By.name("q"));
// Enter something to search for
element.sendKeys("Cheese!");
//start recording the data for transaction
plugin.record();
// Now submit the form. WebDriver will find the form for us from the element
element.submit();
controller.wait_(plugin, -1);
//stop recording for transaction
plugin.stop();
// Save the log file
plugin.log().save("C:/<local path>/googletest.hwl");
} }
We can also Print Performance metrics of page
Selenium Automation with HTTPWatch Plug-in Sandeep.tol@outlook.com 9
/*Get the Summary of Performance KPI*/
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 received on 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());
The Execution Console Output will look like this
Auto generated HWL File would like this. You can also
export this content to CSV format
Selenium Automation with HTTPWatch Plug-in Sandeep.tol@outlook.com 10
 If you would like to simulate the HTTP Watch with Mozilla Firefox . Below is the
code .There are few minor modifications needed to invoke HTTPWatch plugin .
Please note the HTTPwatch plugin only works for Firefox version 35 and
below
FirefoxProfile profile = new FirefoxProfile();
// FireBug,NetExport,Modify Headers xpi
File httpwatch = new File("C:Program Files (x86)HttpWatchFirefox");
profile.setEnableNativeEvents(false);
try {
profile.addExtension(httpwatch);
} catch (IOException err) {
System.out.println(err);
}
WebDriver driver = new FirefoxDriver(profile);
driver.get("http://www.google.com");
String title = driver.getTitle();
System.out.println(" Title1 - " + title);
Plugin plugin = controller.attachByTitle(title);
Rest of the code is same for Plugin recording and transaction simulationss
Selenium Automation with HTTPWatch Plug-in Sandeep.tol@outlook.com 11
 Download Code Project from GiHub
https://github.com/sandeeptol1/SampleJavaHttpWatchAutomation
 Software Test Automation is brining lot of innovative tools and techniques to
automate manual testing and reduce testing efforts. Especially in Agile Projects or
Next gen architectures, automation is the key to successful project
implementations. Many Enterprises are using automated scripts for Junit tests,
Selenium Web browser Tests in their CI/CD ( Continuous Integration)
frameworks to reduce cycle time and manual efforts on Unit testing, Browser
testing & regression testing . Automation is “mantra” in nexgen architecture.
 Selenium can be used for automating regression tests and browser based tests or
Website comparison tests against competition. Using above techniques httplogs
can also be collected during such tests . This data can be stored in some database
or files and can be shown in dashboards to view website performance
 References
HTTPWatch API http://apihelp.httpwatch.com/#Automation%20Overview.html
COM 4 Java https://com4j.java.net/tutorial.html
Selenium Webdriver http://www.seleniumhq.org/projects/webdriver/
Selenium Automation with HTTPWatch Plug-in Sandeep.tol@outlook.com 12
About the Author
 Sandeep Tol is Senior Architect at Wipro, with technology experience spanning
across Java J2EE applications, Web Portals, SOA platforms, Digital, Mobile, Cloud
architectures & Performance Engineering .Certified in TOGAF 9, written various
whitepapers published on architecture and quality governance.
Has Special Interest in Test Automation and Performance Engineering .Developed
and implemented various performance engineering automation tools,’ left shift
strategies to various customers
https://www.linkedin.com/in/sandeeptol
email: sandeep.tol@outlook.com
Selenium Automation with HTTPWatch Plug-in Sandeep.tol@outlook.com 13
Ad

Recommended

Using HttpWatch Plug-in with Selenium Automation in Java
Using HttpWatch Plug-in with Selenium Automation in Java
Sandeep Tol
 
Spring Boot
Spring Boot
Jaydeep Kale
 
Vue.js Getting Started
Vue.js Getting Started
Murat Doğan
 
Selenium
Selenium
eduquer
 
Spring framework core
Spring framework core
Taemon Piya-Lumyong
 
Spring boot
Spring boot
Gyanendra Yadav
 
My Journey to Becoming a Docker Captain
My Journey to Becoming a Docker Captain
Ajeet Singh Raina
 
An overview of selenium webdriver
An overview of selenium webdriver
Anuraj S.L
 
Spring boot introduction
Spring boot introduction
Rasheed Waraich
 
Selenium
Selenium
Batch2016
 
spring-boot-fr.pdf
spring-boot-fr.pdf
seydou4devops
 
Spring Boot in Action
Spring Boot in Action
Alex Movila
 
Selenium
Selenium
Kalyan ch
 
Implicit and Explicit waits in Selenium WebDriwer, how to.
Implicit and Explicit waits in Selenium WebDriwer, how to.
Yaroslav Pernerovsky
 
Basics of VueJS
Basics of VueJS
Squash Apps Pvt Ltd
 
Automation - web testing with selenium
Automation - web testing with selenium
Tzirla Rozental
 
Cypress Automation
Cypress Automation
Susantha Pathirana
 
Spring Boot Tutorial
Spring Boot Tutorial
Naphachara Rattanawilai
 
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Edureka!
 
Webdriver.io
Webdriver.io
LinkMe Srl
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
Grails Connecting to MySQL
Grails Connecting to MySQL
ashishkirpan
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
Zoe Gilbert
 
Dev ops using Jenkins
Dev ops using Jenkins
Synergetics Learning and Cloud Consulting
 
Xke spring boot
Xke spring boot
sourabh aggarwal
 
Angular 9
Angular 9
Raja Vishnu
 
Web Worker, Service Worker and Worklets
Web Worker, Service Worker and Worklets
Keshav Gupta
 
Spring Native and Spring AOT
Spring Native and Spring AOT
VMware Tanzu
 
Web Testen mit Selenium
Web Testen mit Selenium
openForce Information Technology GesmbH
 
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
Matthew Allen
 

More Related Content

What's hot (20)

Spring boot introduction
Spring boot introduction
Rasheed Waraich
 
Selenium
Selenium
Batch2016
 
spring-boot-fr.pdf
spring-boot-fr.pdf
seydou4devops
 
Spring Boot in Action
Spring Boot in Action
Alex Movila
 
Selenium
Selenium
Kalyan ch
 
Implicit and Explicit waits in Selenium WebDriwer, how to.
Implicit and Explicit waits in Selenium WebDriwer, how to.
Yaroslav Pernerovsky
 
Basics of VueJS
Basics of VueJS
Squash Apps Pvt Ltd
 
Automation - web testing with selenium
Automation - web testing with selenium
Tzirla Rozental
 
Cypress Automation
Cypress Automation
Susantha Pathirana
 
Spring Boot Tutorial
Spring Boot Tutorial
Naphachara Rattanawilai
 
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Edureka!
 
Webdriver.io
Webdriver.io
LinkMe Srl
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
Cuelogic Technologies Pvt. Ltd.
 
Grails Connecting to MySQL
Grails Connecting to MySQL
ashishkirpan
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
Zoe Gilbert
 
Dev ops using Jenkins
Dev ops using Jenkins
Synergetics Learning and Cloud Consulting
 
Xke spring boot
Xke spring boot
sourabh aggarwal
 
Angular 9
Angular 9
Raja Vishnu
 
Web Worker, Service Worker and Worklets
Web Worker, Service Worker and Worklets
Keshav Gupta
 
Spring Native and Spring AOT
Spring Native and Spring AOT
VMware Tanzu
 
Spring boot introduction
Spring boot introduction
Rasheed Waraich
 
Spring Boot in Action
Spring Boot in Action
Alex Movila
 
Implicit and Explicit waits in Selenium WebDriwer, how to.
Implicit and Explicit waits in Selenium WebDriwer, how to.
Yaroslav Pernerovsky
 
Automation - web testing with selenium
Automation - web testing with selenium
Tzirla Rozental
 
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Selenium Training | TestNG Framework For Selenium | Selenium Tutorial For Beg...
Edureka!
 
Grails Connecting to MySQL
Grails Connecting to MySQL
ashishkirpan
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
Zoe Gilbert
 
Web Worker, Service Worker and Worklets
Web Worker, Service Worker and Worklets
Keshav Gupta
 
Spring Native and Spring AOT
Spring Native and Spring AOT
VMware Tanzu
 

Similar to Selenium Automation in Java Using HttpWatch Plug-in (20)

Web Testen mit Selenium
Web Testen mit Selenium
openForce Information Technology GesmbH
 
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
Matthew Allen
 
Intelligent Testing Tool: Selenium Web Driver
Intelligent Testing Tool: Selenium Web Driver
IRJET Journal
 
Steps to write Selenium
Steps to write Selenium
Rohit Thakur
 
Web driver selenium simplified
Web driver selenium simplified
Vikas Singh
 
Selenium web driver
Selenium web driver
Roman Savitskiy
 
IRJET- Automatic Device Functional Testing
IRJET- Automatic Device Functional Testing
IRJET Journal
 
Selenium with testng and eclipse ide
Selenium with testng and eclipse ide
Testertester Jaipur
 
TAFs on WebDriver API - By - Pallavi Sharma.pdf
TAFs on WebDriver API - By - Pallavi Sharma.pdf
Pallavi Sharma
 
Selenium Full Material( apprendre Selenium).pdf
Selenium Full Material( apprendre Selenium).pdf
Sdiri Ahmed
 
Quest to the best test automation for low code development platform kherrazi ...
Quest to the best test automation for low code development platform kherrazi ...
Rachid Kherrazi
 
AUTOMATION TESTING tools extensive application
AUTOMATION TESTING tools extensive application
ssuser94400e
 
Selenium -Test automation for web applications
Selenium -Test automation for web applications
AnisGhelissi
 
Selenium
Selenium
David Rajah Selvaraj
 
Selenium for Tester.pdf
Selenium for Tester.pdf
RTechRInfoIT
 
DrupalCon Dublin 2016 - Automated browser testing with Nightwatch.js
DrupalCon Dublin 2016 - Automated browser testing with Nightwatch.js
Vladimir Roudakov
 
Selenium With Spices
Selenium With Spices
Nikolajs Okunevs
 
Operationalization of a solution to automate web forms insertions in the Offi...
Operationalization of a solution to automate web forms insertions in the Offi...
Pedro Sobreiro
 
All levels of performance testing and monitoring in web-apps
All levels of performance testing and monitoring in web-apps
Andrii Skrypnychenko
 
Automated Testing with Google Chrome - WebDriver- ChromeDriver
Automated Testing with Google Chrome - WebDriver- ChromeDriver
Manoj Kumar Kumar
 
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
Matthew Allen
 
Intelligent Testing Tool: Selenium Web Driver
Intelligent Testing Tool: Selenium Web Driver
IRJET Journal
 
Steps to write Selenium
Steps to write Selenium
Rohit Thakur
 
Web driver selenium simplified
Web driver selenium simplified
Vikas Singh
 
IRJET- Automatic Device Functional Testing
IRJET- Automatic Device Functional Testing
IRJET Journal
 
Selenium with testng and eclipse ide
Selenium with testng and eclipse ide
Testertester Jaipur
 
TAFs on WebDriver API - By - Pallavi Sharma.pdf
TAFs on WebDriver API - By - Pallavi Sharma.pdf
Pallavi Sharma
 
Selenium Full Material( apprendre Selenium).pdf
Selenium Full Material( apprendre Selenium).pdf
Sdiri Ahmed
 
Quest to the best test automation for low code development platform kherrazi ...
Quest to the best test automation for low code development platform kherrazi ...
Rachid Kherrazi
 
AUTOMATION TESTING tools extensive application
AUTOMATION TESTING tools extensive application
ssuser94400e
 
Selenium -Test automation for web applications
Selenium -Test automation for web applications
AnisGhelissi
 
Selenium for Tester.pdf
Selenium for Tester.pdf
RTechRInfoIT
 
DrupalCon Dublin 2016 - Automated browser testing with Nightwatch.js
DrupalCon Dublin 2016 - Automated browser testing with Nightwatch.js
Vladimir Roudakov
 
Operationalization of a solution to automate web forms insertions in the Offi...
Operationalization of a solution to automate web forms insertions in the Offi...
Pedro Sobreiro
 
All levels of performance testing and monitoring in web-apps
All levels of performance testing and monitoring in web-apps
Andrii Skrypnychenko
 
Automated Testing with Google Chrome - WebDriver- ChromeDriver
Automated Testing with Google Chrome - WebDriver- ChromeDriver
Manoj Kumar Kumar
 
Ad

Recently uploaded (20)

FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Kubernetes Security Act Now Before It’s Too Late
Kubernetes Security Act Now Before It’s Too Late
Michael Furman
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
Providing an OGC API Processes REST Interface for FME Flow
Providing an OGC API Processes REST Interface for FME Flow
Safe Software
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
National Fuels Treatments Initiative: Building a Seamless Map of Hazardous Fu...
Safe Software
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Integration of Utility Data into 3D BIM Models Using a 3D Solids Modeling Wor...
Safe Software
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Ad

Selenium Automation in Java Using HttpWatch Plug-in

  • 2. Selenium Automation with HTTPWatch Plugin  Selenium framework allows to simulate real browser like Internet explorer, Chrome or Firefox and automate the execution of user navigations via scripts in the browser. There are enormous articles, tutorials available on automation with selenium. However there is focus given for capturing web page performance KPIs,page load times & Browser HTTP network logs during such Selenium test runs.  Currently there is no Java API available to interface Http Watch plug-in API. solution given in this article show how to use HTTP Watch browser plug-in ,collect logs and measure page performance with Java .  This document would help developers/Testers to write to use Java programming for selenium scripts with capturing HTTP log data using HTTPWatch plugin & capture performance KPI of pages and automate in detection of web performance issues. Selenium Automation with HTTPWatch Plug-in [email protected] 2
  • 3. About HTTPWatch Plug-in  HttpWatch browser plug-in helps to measure Performance of web pages like Page Load time, Number of Javaacript files, Number of CSS files, Number of HTTP Errors, Number of requests etc in Internet Explorer or Firefox . HTTP Watch is external plug-in available in Basic & professional edition for Internet explorer to capture HTTP logs. One can also buy Professional Edition that comes with more features for detailed analysis. Free Basic edition is enough for most of the cases! Selenium Automation with HTTPWatch Plug-in [email protected] 3
  • 4. Java Interfacing for Http Watch Plugin  HTTP Watch comes with inbuilt API support to integrate with selenium scripts written in C# or PHP scripts . Refer http://apihelp.httpwatch.com/#Automation%20Overview.html  But unfortunately we don’t have API written for JAVA. The solution is to use Java COM bridge and invoke HTTP Watch plugin API from Java selenium scripts. Selenium Automation with HTTPWatch Plug-in [email protected] 4 HttpWatch Plugin -Record -Stop -Log Java Selenium Code JavaComBridge Pages Summary -Load Times, URL Data - Content Sizes (CSS/JSS,IMG sizes) , Save Log files HWL Files ( Log files) Java Based HttpWatch Automation with Selenium Controller
  • 5.  Step 1 : Download and install HTTPwatch plug-in for IE in your system. You can download here download Ensure that latest Install JRE or JDK is available on system  Step 2 : Download COM Bridge https://java.net/projects/com4j/downloads and unzip files . There are few other commercial java com bridge available. But I found the above one is good and efficient . You can also refer to tutorial on converting various COM objects into Java interfaces here. https://com4j.java.net/tutorial.html  Step 3 : Open “Command Prompt” and navigate to the folder where you have extracted Com4J files . Copy HTTPWatchx64.dll ( for 32 bit Windows it would be httpwatch.dll) from HTTPwatch plugin installation folder to same folder where COM4J files are extracted. On Windows the HTTPwatch would be installed in C:Program Files (x86)HttpWatch Selenium Automation with HTTPWatch Plug-in [email protected] 5
  • 6.  Step 4 : Convert COM component to Java API . Execute following command Java – jar tlbimp.jar -o <outputFolder> –p <packagename> DLL file Below command would generate files in “output” folder Java – jar tlbimp.jar -o outputFolder –p com.httpwatch httpwatchx64.dll Selenium Automation with HTTPWatch Plug-in [email protected] 6 Generated Java Interface files for HTTPWatch Plugin
  • 7. Java Selenium Code with Http Watch Plugin  Include the httpwatch API that was generated into your selenium project. Below is the code used in Ecipse IDE after importing httpWatch API classes. Selenium Automation with HTTPWatch Plug-in [email protected] 7
  • 8. Java Selenium Code with Http Watch Plugin Selenium Automation with HTTPWatch Plug-in [email protected] 8 public class SeleniumIEHttpwatch { public static void main(String[] args) { InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); WebDriver driver = new InternetExplorerDriver(capabilitiesIE); IController controller = ClassFactory.createController(); driver.manage().window().maximize(); // And now use this to visit Google driver.get("http://www.google.com"); // Check the title of the page String title = driver.getTitle(); // Creae Plugin instance Plugin plugin = controller.attachByTitle(title); // Do some transaction in page e.g Search //WebElement element = driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Cheese!"); //start recording the data for transaction plugin.record(); // Now submit the form. WebDriver will find the form for us from the element element.submit(); controller.wait_(plugin, -1); //stop recording for transaction plugin.stop(); // Save the log file plugin.log().save("C:/<local path>/googletest.hwl"); } }
  • 9. We can also Print Performance metrics of page Selenium Automation with HTTPWatch Plug-in [email protected] 9 /*Get the Summary of Performance KPI*/ 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 received on 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()); The Execution Console Output will look like this
  • 10. Auto generated HWL File would like this. You can also export this content to CSV format Selenium Automation with HTTPWatch Plug-in [email protected] 10
  • 11.  If you would like to simulate the HTTP Watch with Mozilla Firefox . Below is the code .There are few minor modifications needed to invoke HTTPWatch plugin . Please note the HTTPwatch plugin only works for Firefox version 35 and below FirefoxProfile profile = new FirefoxProfile(); // FireBug,NetExport,Modify Headers xpi File httpwatch = new File("C:Program Files (x86)HttpWatchFirefox"); profile.setEnableNativeEvents(false); try { profile.addExtension(httpwatch); } catch (IOException err) { System.out.println(err); } WebDriver driver = new FirefoxDriver(profile); driver.get("http://www.google.com"); String title = driver.getTitle(); System.out.println(" Title1 - " + title); Plugin plugin = controller.attachByTitle(title); Rest of the code is same for Plugin recording and transaction simulationss Selenium Automation with HTTPWatch Plug-in [email protected] 11
  • 12.  Download Code Project from GiHub https://github.com/sandeeptol1/SampleJavaHttpWatchAutomation  Software Test Automation is brining lot of innovative tools and techniques to automate manual testing and reduce testing efforts. Especially in Agile Projects or Next gen architectures, automation is the key to successful project implementations. Many Enterprises are using automated scripts for Junit tests, Selenium Web browser Tests in their CI/CD ( Continuous Integration) frameworks to reduce cycle time and manual efforts on Unit testing, Browser testing & regression testing . Automation is “mantra” in nexgen architecture.  Selenium can be used for automating regression tests and browser based tests or Website comparison tests against competition. Using above techniques httplogs can also be collected during such tests . This data can be stored in some database or files and can be shown in dashboards to view website performance  References HTTPWatch API http://apihelp.httpwatch.com/#Automation%20Overview.html COM 4 Java https://com4j.java.net/tutorial.html Selenium Webdriver http://www.seleniumhq.org/projects/webdriver/ Selenium Automation with HTTPWatch Plug-in [email protected] 12
  • 13. About the Author  Sandeep Tol is Senior Architect at Wipro, with technology experience spanning across Java J2EE applications, Web Portals, SOA platforms, Digital, Mobile, Cloud architectures & Performance Engineering .Certified in TOGAF 9, written various whitepapers published on architecture and quality governance. Has Special Interest in Test Automation and Performance Engineering .Developed and implemented various performance engineering automation tools,’ left shift strategies to various customers https://www.linkedin.com/in/sandeeptol email: [email protected] Selenium Automation with HTTPWatch Plug-in [email protected] 13