SlideShare a Scribd company logo
Find me on LinkedIn - https://www.linkedin.com/in/upgundecha/ | Twitter @upgundecha
Unmesh Gundecha
Senior Architect, Test Engineering DveOps and
Developer Experience (DX)
CP-SAT SELENIUM SUMMIT 2021
Selenium
Power Tools
Quick Poll
Selenium is not a testing tool!
Selenium automates browsers. That's it!
What you do with that power is entirely up to you.
www.selenium.dev
Selenium Use Cases
• Create Macro for automating repetitive tasks in a Browser window
• Screen scrapping – e.g., find cheap hotels, flights…
• Personal productivity – Filling timesheets, checking status
• Stock trading (yeah!)
• Robotic Process Automation
• and most importantly testing or checking! (as in automated test execution tool)
The Selenium Iceberg
Selenium
HTML, CSS, XPath
JavaScript
Programming
Languages, OOAD, Design
Pattern, Clean Code
IDE, Version control
tool
xUnit, BDD
Framework,
Assertional Libraries
(Testing)
Orchestration Tool
(RPA)
Reporting tool
(Testing)
Build and CI Tools
(Maven, Gradle,
Jenkins)
Utilities
(Power Tools)
Selenium Stacks
Selenium Client Library
Programming Language
Macros & Input Data
As a Browser automation Macro
Selenium Client Library
Programming Language
Testing Framework
Reporting & Logging
Test Cases & Test Data
As a Testing Tool
Selenium Client Library
Programming Language
Orchestration Tool
Audit & Logging
Workflows & Event Data
As a RPA Tool
Frequently asked questions
• Does Selenium support Windows or Java Applications, Mainframes?
• Can we automate APIs with Selenium?
• How to test PDFs with Selenium?
• How to automate downloading browser drivers?
• How to take element screenshots?
• How to compare images in Selenium?
• How to check text on a image using Selenium?
• How to generate test data for Selenium tests?
• How to remove flakiness of tests due to application dependencies?
• and many more...
Stacks with Power Tools
Selenium Client Library
Programming Language
Macros & Input Data
Power tools (Utilities)
As a Browser automation Macro
Selenium Client Library
Programming Language
Testing Framework
Reporting & Logging
Test Cases & Test Data
Power tools (Utilities)
As a Testing Tool
Selenium Client Library
Programming Language
Orchestration Tool
Audit & Logging
Workflows & Event Data
Power tools (Utilities)
As a RPA Tool
Selenium Client Library
Programming Language
Macros & Input Data
In order to support such requirements, you can combine Selenium with other libraries (Power tools)
Orchestration Tool
Everything that we discuss in this session is Open
Source, no commercial or protected freeware stuff!
#respect #open-source
Six Power Tools
WebDriverManager ShutterBug Tesseract
Faker & Friends WireMock PDFBox
WebDriverManager
• WebDriverManager is a library which allows to automate the management of the
drivers (e.g. chromedriver, geckodriver, etc.) required by Selenium WebDriver
• Once configured WebDriverManager will automatically download configured
browser drivers for your tests
• Use as a dependency, command line tool, server, docker container…
• Find out the browser version
• Download the driver version
compatible with the browser version
• Set system property in test with the
location of binary
WebDriverManager – How to use it?
• Add WebDriverManager dependency
• Select the browser which you need,
that’s it! WebDriverManager will do
the magic for you
@Before
public void setup() {
System.setProperty("webdriver.chrome.driver",
"/Users/upgundecha/Downloads");
driver = new ChromeDriver();
}
@Before
public void setup() {
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();
}
ShutterBug
• Selenium Shutterbug is a utility library written in Java for making screenshots
using Selenium WebDriver and further customizing, comparing and processing
them with the help of Java AWT
• Selenium Screenshots on steroids
ShutterBug – Use Cases
• Capturing the entire page, WebElement, entire scrollable WebElement, frame
• Creating thumbnails
• Screenshot customizations:
• Highlighting element on the page, with added text
• Blur WebElement on the page (e.g. sensitive information)
• Blur whole page
• Blur whole page except specific WebElement
• Monochrome WebElement
• Crop around specific WebElement with offsets
• Screenshot comparison (with diff highlighting)
ShutterBug– How to use it?
// capture entire page
Shutterbug.shootPage(driver, Capture.FULL, true).save();
// blur and annotate
Shutterbug.shootPage(driver)
.blur(searchBox)
.monochrome(storeLogo)
.highlightWithText(storeLogo, Color.blue, 3, "Monochromed logo", Color.blue, new
Font("SansSerif", Font.BOLD, 20))
.highlightWithText(searchBox, "Blurred secret words")
.withTitle("Store home page - " + new Date())
.withName("home_page")
.withThumbnail(0.7).save();
// image comparison
String baselineFilePath = new File("src/test/resources/baseline_img/first_promo_banner.png")
.getAbsolutePath();
Assert.assertTrue(Shutterbug
.shootElement(driver, firstPromoBanner)
.equalsWithDiff(baselineFilePath,"diff",0.1));
Tesseract
• Tesseract OCR is an optical character reading engine originally developed by HP
in 1985 and open sourced in 2005. Since 2006 it is developed by Google.
Tesseract has Unicode (UTF-8) support and can recognize over 100 languages
“out of the box”
• Useful for capturing text from images, barcodes etc.
• Use with caution!
Tesseract – How to use it?
WebElement promoBanner = driver.findElement(By
.cssSelector("ul.promos> li:nth-child(1) > a"));
BufferedImage bannerImg = Shutterbug.shootElement(driver, promoBanner).getImage();
Tesseract tesseract = new Tesseract();
tesseract.setDatapath("/usr/local/Cellar/tesseract/4.1.1/share/tessdata/");
tesseract.setLanguage("eng");
String result = tesseract.doOCR(bannerImg).trim();
Assert.assertEquals("HOME & DECORnFOR ALL YOUR SPACES", result);
Faker & Friends
• Faker & friends are set of libraries available in various programming languages to
generate fake data for development and testing
• Faker can help in generating test data on the fly instead of manually finding data
every time before you run a test
• Faker libraries can generate data for over 100 data domains such as Names,
Addresses, Emails etc. in various locales.
• Faker can be extended to support custom data domains
more…
Faker & Friends – How to use it?
Faker faker = new Faker();
String firstName = faker.name().firstName();
String lastName = faker.name().lastName();
String email = faker.internet().emailAddress();
String password = "P@ssword";
String greetings = String.format("Hello, %s %s!", firstName, lastName);
WireMock
• Wiremock helps in mocking HTTP services. You can stub HTTP responses in
JSON/XML for development and testing
• Also known as test doubles or service virtualization
• Wiremock can be used as a library in your Selenium projects or as standalone
instance
• There are bunch of other alternative available. Check out my awesome-toolbox
page
WireMock – How to use it?
// Setup and start the Wiremock server
WireMockServer wireMockServer = new WireMockServer(options()
.port(4000)
.notifier(new ConsoleNotifier(true)));
wireMockServer.start();
// Define stub for the test
wireMockServer
.stubFor(get(urlEqualTo("/data/2.5/weather?q=Singapore&appid
=undefined&units=metric"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type",
"application/json")
.withBodyFile("json/weather_data.json")));
PDFBox
• The Apache PDFBox library is an open-source Java tool for working with PDF
documents.
• PDFBox allows creation of new PDF documents, manipulation of existing
documents and the ability to extract content from documents
• Similar libraries available in other programming languages
• PDFBox can help you testing PDFs
• Use with caution!
PDFBox – How to use it?
doc = PDDocument.load(file);
Assert.assertEquals(1, doc.getNumberOfPages());
String content = new PDFTextStripper().getText(doc);
Assert.assertTrue(content.contains("PDF Test File"));
Demos!
Examples for this session are written in Java and JUnit
Most of these tools have alternate versions available in
other popular programming languages (Python, C#,
Ruby, JavaScript)
Resources
• Code from this session - https://github.com/upgundecha/se-powertools-recipes
• Awesome Toolbox - https://github.com/upgundecha/awesome-toolbox
• Awesome Selenium List - https://github.com/christian-bromann/awesome-
selenium
How to create your Power Toolbox
• Keep looking for libraries & tools in
• GitHub Explore
• Package Repositories such as npmjs.org, PyPI (Python Package Index),
rubygems.org
• Create awesome list in your GitHub Repo
My Books & Blog
https://www.amazon.com/~/e/B00ATKDJOA
Thank you!

More Related Content

Similar to Session on Selenium Powertools by Unmesh Gundecha (20)

ZIP
From IDE to Selenium 2
davehunt82
 
PPTX
Automated Testing on Web Applications
Samuel Borg
 
PPTX
Selenium.pptx
Pandiya Rajan
 
PDF
Selenium for Tester.pdf
RTechRInfoIT
 
PPT
selenium training | selenium course | selenium video tutorial | selenium for ...
Nancy Thomas
 
PPTX
Selenium Automation
Anuradha Malalasena
 
PPTX
Open Source Automation Tools That Really Work V2
An Doan
 
PPTX
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
Simplilearn
 
PPTX
Test Automation Using Selenium
Nikhil Kapoor
 
PPTX
Introduction to APIs & how to automate APIs testing with selenium web driver?
BugRaptors
 
PPTX
Selenium presentation
shivani thakur
 
PPTX
Selenium
abiramimaya
 
PPTX
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
Matthew Allen
 
PPTX
Selenium.pptx
orbitprojects
 
PDF
Selenium
eduquer
 
PPTX
Introduction to Selenium Web Driver
Return on Intelligence
 
KEY
Getting started with Selenium 2
Sebastiano Armeli
 
PPTX
Selenium
mdfkhan625
 
PPT
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
PPTX
Selenium Basics and Overview topics.pptx
sountharyaravi010
 
From IDE to Selenium 2
davehunt82
 
Automated Testing on Web Applications
Samuel Borg
 
Selenium.pptx
Pandiya Rajan
 
Selenium for Tester.pdf
RTechRInfoIT
 
selenium training | selenium course | selenium video tutorial | selenium for ...
Nancy Thomas
 
Selenium Automation
Anuradha Malalasena
 
Open Source Automation Tools That Really Work V2
An Doan
 
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
Simplilearn
 
Test Automation Using Selenium
Nikhil Kapoor
 
Introduction to APIs & how to automate APIs testing with selenium web driver?
BugRaptors
 
Selenium presentation
shivani thakur
 
Selenium
abiramimaya
 
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
Matthew Allen
 
Selenium.pptx
orbitprojects
 
Selenium
eduquer
 
Introduction to Selenium Web Driver
Return on Intelligence
 
Getting started with Selenium 2
Sebastiano Armeli
 
Selenium
mdfkhan625
 
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
Selenium Basics and Overview topics.pptx
sountharyaravi010
 

More from Agile Testing Alliance (20)

PPTX
#Interactive Session by Anindita Rath and Mahathee Dandibhotla, "From Good to...
Agile Testing Alliance
 
PDF
#Interactive Session by Ajay Balamurugadas, "Where Are The Real Testers In T...
Agile Testing Alliance
 
PPTX
#Interactive Session by Jishnu Nambiar and Mayur Ovhal, "Monitoring Web Per...
Agile Testing Alliance
 
PDF
#Interactive Session by Pradipta Biswas and Sucheta Saurabh Chitale, "Navigat...
Agile Testing Alliance
 
PDF
#Interactive Session by Apoorva Ram, "The Art of Storytelling for Testers" at...
Agile Testing Alliance
 
PPTX
#Interactive Session by Nikhil Jain, "Catch All Mail With Graph" at #ATAGTR2023.
Agile Testing Alliance
 
PPTX
#Interactive Session by Ashok Kumar S, "Test Data the key to robust test cove...
Agile Testing Alliance
 
PPTX
#Interactive Session by Seema Kohli, "Test Leadership in the Era of Artificia...
Agile Testing Alliance
 
PDF
#Interactive Session by Ashwini Lalit, RRR of Test Automation Maintenance" at...
Agile Testing Alliance
 
PPTX
#Interactive Session by Srithanga Aishvarya T, "Machine Learning Model to aut...
Agile Testing Alliance
 
PPTX
#Interactive Session by Kirti Ranjan Satapathy and Nandini K, "Elements of Qu...
Agile Testing Alliance
 
PPTX
#Interactive Session by Sudhir Upadhyay and Ashish Kumar, "Strengthening Test...
Agile Testing Alliance
 
PPTX
#Interactive Session by Sayan Deb Kundu, "Testing Gen AI Applications" at #AT...
Agile Testing Alliance
 
PDF
#Interactive Session by Dinesh Boravke, "Zero Defects – Myth or Reality" at #...
Agile Testing Alliance
 
PPTX
#Interactive Session by Saby Saurabh Bhardwaj, "Redefine Quality Assurance –...
Agile Testing Alliance
 
PDF
#Keynote Session by Sanjay Kumar, "Innovation Inspired Testing!!" at #ATAGTR2...
Agile Testing Alliance
 
PDF
#Keynote Session by Schalk Cronje, "Don’t Containerize me" at #ATAGTR2023.
Agile Testing Alliance
 
PPTX
#Interactive Session by Chidambaram Vetrivel and Venkatesh Belde, "Revolution...
Agile Testing Alliance
 
PDF
#Interactive Session by Aniket Diwakar Kadukar and Padimiti Vaidik Eswar Dat...
Agile Testing Alliance
 
PPTX
#Interactive Session by Vivek Patle and Jahnavi Umarji, "Empowering Functiona...
Agile Testing Alliance
 
#Interactive Session by Anindita Rath and Mahathee Dandibhotla, "From Good to...
Agile Testing Alliance
 
#Interactive Session by Ajay Balamurugadas, "Where Are The Real Testers In T...
Agile Testing Alliance
 
#Interactive Session by Jishnu Nambiar and Mayur Ovhal, "Monitoring Web Per...
Agile Testing Alliance
 
#Interactive Session by Pradipta Biswas and Sucheta Saurabh Chitale, "Navigat...
Agile Testing Alliance
 
#Interactive Session by Apoorva Ram, "The Art of Storytelling for Testers" at...
Agile Testing Alliance
 
#Interactive Session by Nikhil Jain, "Catch All Mail With Graph" at #ATAGTR2023.
Agile Testing Alliance
 
#Interactive Session by Ashok Kumar S, "Test Data the key to robust test cove...
Agile Testing Alliance
 
#Interactive Session by Seema Kohli, "Test Leadership in the Era of Artificia...
Agile Testing Alliance
 
#Interactive Session by Ashwini Lalit, RRR of Test Automation Maintenance" at...
Agile Testing Alliance
 
#Interactive Session by Srithanga Aishvarya T, "Machine Learning Model to aut...
Agile Testing Alliance
 
#Interactive Session by Kirti Ranjan Satapathy and Nandini K, "Elements of Qu...
Agile Testing Alliance
 
#Interactive Session by Sudhir Upadhyay and Ashish Kumar, "Strengthening Test...
Agile Testing Alliance
 
#Interactive Session by Sayan Deb Kundu, "Testing Gen AI Applications" at #AT...
Agile Testing Alliance
 
#Interactive Session by Dinesh Boravke, "Zero Defects – Myth or Reality" at #...
Agile Testing Alliance
 
#Interactive Session by Saby Saurabh Bhardwaj, "Redefine Quality Assurance –...
Agile Testing Alliance
 
#Keynote Session by Sanjay Kumar, "Innovation Inspired Testing!!" at #ATAGTR2...
Agile Testing Alliance
 
#Keynote Session by Schalk Cronje, "Don’t Containerize me" at #ATAGTR2023.
Agile Testing Alliance
 
#Interactive Session by Chidambaram Vetrivel and Venkatesh Belde, "Revolution...
Agile Testing Alliance
 
#Interactive Session by Aniket Diwakar Kadukar and Padimiti Vaidik Eswar Dat...
Agile Testing Alliance
 
#Interactive Session by Vivek Patle and Jahnavi Umarji, "Empowering Functiona...
Agile Testing Alliance
 
Ad

Recently uploaded (20)

PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
July Patch Tuesday
Ivanti
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Ad

Session on Selenium Powertools by Unmesh Gundecha

  • 1. Find me on LinkedIn - https://www.linkedin.com/in/upgundecha/ | Twitter @upgundecha Unmesh Gundecha Senior Architect, Test Engineering DveOps and Developer Experience (DX) CP-SAT SELENIUM SUMMIT 2021 Selenium Power Tools
  • 3. Selenium is not a testing tool! Selenium automates browsers. That's it! What you do with that power is entirely up to you. www.selenium.dev
  • 4. Selenium Use Cases • Create Macro for automating repetitive tasks in a Browser window • Screen scrapping – e.g., find cheap hotels, flights… • Personal productivity – Filling timesheets, checking status • Stock trading (yeah!) • Robotic Process Automation • and most importantly testing or checking! (as in automated test execution tool)
  • 5. The Selenium Iceberg Selenium HTML, CSS, XPath JavaScript Programming Languages, OOAD, Design Pattern, Clean Code IDE, Version control tool xUnit, BDD Framework, Assertional Libraries (Testing) Orchestration Tool (RPA) Reporting tool (Testing) Build and CI Tools (Maven, Gradle, Jenkins) Utilities (Power Tools)
  • 6. Selenium Stacks Selenium Client Library Programming Language Macros & Input Data As a Browser automation Macro Selenium Client Library Programming Language Testing Framework Reporting & Logging Test Cases & Test Data As a Testing Tool Selenium Client Library Programming Language Orchestration Tool Audit & Logging Workflows & Event Data As a RPA Tool
  • 7. Frequently asked questions • Does Selenium support Windows or Java Applications, Mainframes? • Can we automate APIs with Selenium? • How to test PDFs with Selenium? • How to automate downloading browser drivers? • How to take element screenshots? • How to compare images in Selenium? • How to check text on a image using Selenium? • How to generate test data for Selenium tests? • How to remove flakiness of tests due to application dependencies? • and many more...
  • 8. Stacks with Power Tools Selenium Client Library Programming Language Macros & Input Data Power tools (Utilities) As a Browser automation Macro Selenium Client Library Programming Language Testing Framework Reporting & Logging Test Cases & Test Data Power tools (Utilities) As a Testing Tool Selenium Client Library Programming Language Orchestration Tool Audit & Logging Workflows & Event Data Power tools (Utilities) As a RPA Tool Selenium Client Library Programming Language Macros & Input Data In order to support such requirements, you can combine Selenium with other libraries (Power tools) Orchestration Tool
  • 9. Everything that we discuss in this session is Open Source, no commercial or protected freeware stuff! #respect #open-source
  • 10. Six Power Tools WebDriverManager ShutterBug Tesseract Faker & Friends WireMock PDFBox
  • 11. WebDriverManager • WebDriverManager is a library which allows to automate the management of the drivers (e.g. chromedriver, geckodriver, etc.) required by Selenium WebDriver • Once configured WebDriverManager will automatically download configured browser drivers for your tests • Use as a dependency, command line tool, server, docker container…
  • 12. • Find out the browser version • Download the driver version compatible with the browser version • Set system property in test with the location of binary WebDriverManager – How to use it? • Add WebDriverManager dependency • Select the browser which you need, that’s it! WebDriverManager will do the magic for you @Before public void setup() { System.setProperty("webdriver.chrome.driver", "/Users/upgundecha/Downloads"); driver = new ChromeDriver(); } @Before public void setup() { WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(); }
  • 13. ShutterBug • Selenium Shutterbug is a utility library written in Java for making screenshots using Selenium WebDriver and further customizing, comparing and processing them with the help of Java AWT • Selenium Screenshots on steroids
  • 14. ShutterBug – Use Cases • Capturing the entire page, WebElement, entire scrollable WebElement, frame • Creating thumbnails • Screenshot customizations: • Highlighting element on the page, with added text • Blur WebElement on the page (e.g. sensitive information) • Blur whole page • Blur whole page except specific WebElement • Monochrome WebElement • Crop around specific WebElement with offsets • Screenshot comparison (with diff highlighting)
  • 15. ShutterBug– How to use it? // capture entire page Shutterbug.shootPage(driver, Capture.FULL, true).save(); // blur and annotate Shutterbug.shootPage(driver) .blur(searchBox) .monochrome(storeLogo) .highlightWithText(storeLogo, Color.blue, 3, "Monochromed logo", Color.blue, new Font("SansSerif", Font.BOLD, 20)) .highlightWithText(searchBox, "Blurred secret words") .withTitle("Store home page - " + new Date()) .withName("home_page") .withThumbnail(0.7).save(); // image comparison String baselineFilePath = new File("src/test/resources/baseline_img/first_promo_banner.png") .getAbsolutePath(); Assert.assertTrue(Shutterbug .shootElement(driver, firstPromoBanner) .equalsWithDiff(baselineFilePath,"diff",0.1));
  • 16. Tesseract • Tesseract OCR is an optical character reading engine originally developed by HP in 1985 and open sourced in 2005. Since 2006 it is developed by Google. Tesseract has Unicode (UTF-8) support and can recognize over 100 languages “out of the box” • Useful for capturing text from images, barcodes etc. • Use with caution!
  • 17. Tesseract – How to use it? WebElement promoBanner = driver.findElement(By .cssSelector("ul.promos> li:nth-child(1) > a")); BufferedImage bannerImg = Shutterbug.shootElement(driver, promoBanner).getImage(); Tesseract tesseract = new Tesseract(); tesseract.setDatapath("/usr/local/Cellar/tesseract/4.1.1/share/tessdata/"); tesseract.setLanguage("eng"); String result = tesseract.doOCR(bannerImg).trim(); Assert.assertEquals("HOME & DECORnFOR ALL YOUR SPACES", result);
  • 18. Faker & Friends • Faker & friends are set of libraries available in various programming languages to generate fake data for development and testing • Faker can help in generating test data on the fly instead of manually finding data every time before you run a test • Faker libraries can generate data for over 100 data domains such as Names, Addresses, Emails etc. in various locales. • Faker can be extended to support custom data domains more…
  • 19. Faker & Friends – How to use it? Faker faker = new Faker(); String firstName = faker.name().firstName(); String lastName = faker.name().lastName(); String email = faker.internet().emailAddress(); String password = "P@ssword"; String greetings = String.format("Hello, %s %s!", firstName, lastName);
  • 20. WireMock • Wiremock helps in mocking HTTP services. You can stub HTTP responses in JSON/XML for development and testing • Also known as test doubles or service virtualization • Wiremock can be used as a library in your Selenium projects or as standalone instance • There are bunch of other alternative available. Check out my awesome-toolbox page
  • 21. WireMock – How to use it? // Setup and start the Wiremock server WireMockServer wireMockServer = new WireMockServer(options() .port(4000) .notifier(new ConsoleNotifier(true))); wireMockServer.start(); // Define stub for the test wireMockServer .stubFor(get(urlEqualTo("/data/2.5/weather?q=Singapore&appid =undefined&units=metric")) .willReturn(aResponse() .withStatus(200) .withHeader("Content-Type", "application/json") .withBodyFile("json/weather_data.json")));
  • 22. PDFBox • The Apache PDFBox library is an open-source Java tool for working with PDF documents. • PDFBox allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents • Similar libraries available in other programming languages • PDFBox can help you testing PDFs • Use with caution!
  • 23. PDFBox – How to use it? doc = PDDocument.load(file); Assert.assertEquals(1, doc.getNumberOfPages()); String content = new PDFTextStripper().getText(doc); Assert.assertTrue(content.contains("PDF Test File"));
  • 24. Demos! Examples for this session are written in Java and JUnit Most of these tools have alternate versions available in other popular programming languages (Python, C#, Ruby, JavaScript)
  • 25. Resources • Code from this session - https://github.com/upgundecha/se-powertools-recipes • Awesome Toolbox - https://github.com/upgundecha/awesome-toolbox • Awesome Selenium List - https://github.com/christian-bromann/awesome- selenium
  • 26. How to create your Power Toolbox • Keep looking for libraries & tools in • GitHub Explore • Package Repositories such as npmjs.org, PyPI (Python Package Index), rubygems.org • Create awesome list in your GitHub Repo
  • 27. My Books & Blog https://www.amazon.com/~/e/B00ATKDJOA