SlideShare uma empresa Scribd logo
1 de 30
Baixar para ler offline
WebDriverManager:
the Swiss Army Knife for
Selenium WebDriver
Selenium Conference 2022
July 29, 2022
Boni García
boni.garcia.c@saucelabs.com https://bonigarcia.dev
@boni_gg https://github.com/bonigarcia
Presentation
Automated driver management and other
helper features for Selenium WebDriver in Java
Source code: https://github.com/bonigarcia/webdrivermanager
Doc: https://bonigarcia.dev/webdrivermanager/
1. The little history of WebDriverManager
2004
Jason Huggins and
Paul Hammant
created Selenium
core and RC
(Selenium 1)
2007 2009
PhD candidate at
UPM, focused on
software quality and
test automation for
web applications.
I used Selenium RC
for my dissertation
2011 2013
Post-doc researcher
at URJC.
I used Selenium
WebDriver for
assessing WebRTC
apps
2014
Private University
Professor at U-tad. I
gave a course about
web programming
2007
2015
1.0.0
2018
Visiting
Professor
at UC3M
Author of
Packt book
about
JUnit 5
2021
2020
2017
2.0.0
2018
3.0.0
2020
4.0.0 5.0.0
2016
Selenium 3 Selenium 4
2021
2017
Author of
O’Reilly book
about
Selenium 4
PhD
2021
2022
Staff
Software
Engineer at
Sauce Labs
Simon
Stewart
created
WebDriver
Huggins and Stewart
merged Selenium and
WebDriver into Selenium
WebDriver (Selenium 2)
2019
W3C
WebDriver
2020
W3C
WebDriver
BiDi
Assistant
Professor
at URJC
2015
2. The original motivation: automated driver management
• Selenium WebDriver (i.e. Selenium 2+) uses the native
capabilities of each browser to support the automation
2. The original motivation: automated driver management
• For a given browser (e.g. Chrome), I called driver
management to the process of resolving its proper driver
(e.g., chromedriver), and it is composed of three steps:
1. Download
2. Setup
3. Maintenance
2. The original motivation: automated driver management
• Regarding the setup:
- Once the driver is downloaded, to be used by Selenium WebDriver,
it needs to be available in the PATH environment variable
- Alternatively, the driver path needs to be exported using a given
property before creating a WebDriver object
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver");
System.setProperty("webdriver.edge.driver", "/path/to/msedgedriver");
System.setProperty("webdriver.opera.driver", "/path/to/operadriver");
System.setProperty("webdriver.ie.driver", "C:/path/to/IEDriverServer.exe");
2. The original motivation: automated driver management
• Regarding the maintenance:
- Modern web browsers are evergreen (i.e., they automatically and
silently upgrade to the next stable version)
- Due to this upgrade, the driver-browser compatibility is not
satisfied in the long run
chromedriver
98.0.4758.102
Chrome 98
…
chromedriver
98.0.4758.102
Chrome 99
…
chromedriver
98.0.4758.102
Chrome 100
this version of chromedriver only supports
Chrome version N
2. The original motivation: automated driver management
2. The original motivation: automated driver management
• WebDriverManager is an open-source Java library that
carries out the management (i.e., download, setup, and
maintenance) of the drivers required by Selenium
WebDriver (e.g., chromedriver, geckodriver, msedgedriver,
etc.) in a fully automated manner.
WebDriverManager.chromedriver().setup();
WebDriverManager.firefoxdriver().setup();
WebDriverManager.edgedriver().setup();
WebDriverManager.chromiumdriver().setup();
WebDriverManager.operadriver().setup();
WebDriverManager.iedriver().setup();
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.2.2</version>
<scope>test</scope>
</dependency>
dependencies {
testImplementation("io.github.bonigarcia:webdrivermanager:5.2.2")
}
2. The original motivation: automated driver management
class ChromeTest {
WebDriver driver;
@BeforeAll
static void setupClass() {
WebDriverManager.chromedriver().setup();
}
@BeforeEach
void setup() {
driver = new ChromeDriver();
}
@AfterEach
void teardown() {
driver.quit();
}
@Test
public void test() {
// Your test logic here
}
}
public class FirefoxTest {
private WebDriver driver;
@BeforeClass
public static void setupClass() {
WebDriverManager.firefoxdriver().setup();
}
@BeforeMethod
public void setup() {
driver = new FirefoxDriver();
}
@AfterMethod
public void teardown() {
driver.quit();
}
@Test
public void test() {
// Your test logic here
}
}
+ +
2. The original motivation: automated driver management
@ExtendWith(SeleniumJupiter.class)
class HelloWorldChromeSelJupTest {
@Test
void test(ChromeDriver driver) {
// Your test logic here
}
}
+
JUnit 5 extension for Selenium WebDriver
Source code: https://github.com/bonigarcia/selenium-jupiter
Doc: https://bonigarcia.dev/selenium-jupiter/
2. The original motivation: automated driver management
• WebDriverManager was first released on 21st March 2015
• In its earlier versions, WebDriverManager downloaded the
latest version of the driver by default
Check driver
latest version
Driver in
cache?
Download driver
Export driver path Driver
cache
no
Driver repository (online)
yes
setup()
2. The original motivation: automated driver management
• Currently, WebDriverManager resolution algorithm is much richer
García, Boni, et al. "Automated driver
management for Selenium WebDriver."
Empirical Software Engineering (2021)
2. The original motivation: automated driver management
• WebDriverManager exposes a rich fluent API, e.g.:
• WebDriverManager is highly configurable with:
1. Java properties, e.g.:
2. Environment variables, e.g.:
WebDriverManager.chromedriver().browserVersion("99").setup();
WebDriverManager.firefoxdriver().arch32().setup();
WebDriverManager.operadriver().forceDownload().setup();
WebDriverManager.edgedriver().proxy("server:port").setup();
Force a chromedriver version
compatible with Chrome 99
Force 32-bit architecture for
geckodriver
Force the download of operadriver
(even if it is in the cached)
Set proxy setup when managing
msedgedriver
https://bonigarcia.dev/webdrivermanager/
mvn test -Dwdm.cachePath=~/.selenium
export WDM_CACHEPATH=~/.selenium
3. The evolution: WebDriverManager 5
• WebDriverManager 5 was released on August 30, 2021
- As of this version, WebDriverManager provides other features
than automated driver management for Selenium WebDriver
Source code: https://github.com/bonigarcia/selenium-webdriver-java
Practice site: https://bonigarcia.dev/selenium-webdriver-java/
O’Reilly will give three e-books as a
giveaway to the participants in the
following survey about the challenges
and solutions of Selenium WebDriver:
https://forms.gle/QzsSpJD5R2bGx2ZZ7
3. The evolution: WebDriverManager 5
1. Browser finder class SafariTest {
WebDriver driver;
@BeforeAll
static void setupClass() {
Optional<Path> browserPath = WebDriverManager.safaridriver()
.getBrowserPath();
assumeThat(browserPath).isPresent();
}
@BeforeEach
void setupTest() {
driver = new SafariDriver();
}
@AfterEach
void teardown() {
driver.quit();
}
@Test
void test() {
driver.get("https://bonigarcia.dev/selenium-webdriver-java/");
assertThat(driver.getTitle()).contains("Selenium WebDriver");
}
}
WebDriverManager provides the
method getBrowserPath() to find
out if the browser is installed or not
3. The evolution: WebDriverManager 5
2. WebDriver builder
class ChromeCreateTest {
WebDriver driver;
@BeforeEach
void setupTest() {
driver = WebDriverManager.chromedriver().create();
}
@AfterEach
void teardown() {
driver.quit();
}
@Test
void test() {
driver.get("https://bonigarcia.dev/selenium-webdriver-java/");
assertThat(driver.getTitle()).contains("Selenium WebDriver");
}
}
WebDriverManager provides the
method create() to instantiate
WebDriver objects (e.g.,
ChromeDriver, FirefoxDriver,
etc.)
3. The evolution: WebDriverManager 5
3. Browsers in Docker
class DockerChromeTest {
WebDriver driver;
WebDriverManager wdm = WebDriverManager.chromedriver().browserInDocker();
@BeforeEach
void setupTest() {
driver = wdm.create();
}
@AfterEach
void teardown() {
wdm.quit();
}
@Test
void test() {
driver.get("https://bonigarcia.dev/selenium-webdriver-java/");
assertThat(driver.getTitle()).contains("Selenium WebDriver");
}
}
WebDriverManager provides the
method browserInDocker() to
control browsers in Docker containers
https://aerokube.com/images/latest/
3. The evolution: WebDriverManager 5
3. Browsers in Docker
class DockerChromeVncTest {
WebDriver driver;
WebDriverManager wdm = WebDriverManager.chromedriver().browserInDocker()
.enableVnc();
@BeforeEach
void setupTest() {
driver = wdm.create();
}
@AfterEach
void teardown() {
wdm.quit();
}
@Test
void test() throws Exception {
driver.get("https://bonigarcia.dev/selenium-webdriver-java/");
assertThat(driver.getTitle()).contains("Selenium WebDriver");
}
}
The method enableVnc() allows to
connect to the remote desktop using
VNC and noVNC
The method enableRecording()
allows recoding the remote session
using FFmpeg
3. The evolution: WebDriverManager 5
3. Browsers in Docker
class DockerChromeBetaTest {
WebDriver driver;
WebDriverManager wdm = WebDriverManager.chromedriver().browserInDocker()
.browserVersion("beta");
@BeforeEach
void setupTest() {
assumeThat(isDockerAvailable()).isTrue();
driver = wdm.create();
}
@AfterEach
void teardown() {
wdm.quit();
}
@Test
void test() {
driver.get("https://bonigarcia.dev/selenium-webdriver-java/");
assertThat(driver.getTitle()).contains("Selenium WebDriver");
}
}
The method browserVersion()
allows to change the version of the
dockerized browser. This version can be
fixed (e.g., "100"), or the following
wildcards: "latest" or "latest-N".
Also: "beta" and "dev" (for Chrome
and Firefox)
WebDriverManager provides the static
method isDockerAvailable() to
check if there is a Docker engine
installed on the local machine
3. The evolution: WebDriverManager 5
4. Monitoring
• WebDriverManager 5.2.0 provides seamless integration with BrowserWatcher
Source code: https://github.com/bonigarcia/browserwatcher
Doc: https://bonigarcia.dev/browserwatcher/
Browser extension for console monitoring,
tab recording, Content Security Policy (CSP)
disabling, and JavaScript/CSS injection
3. The evolution: WebDriverManager 5
4. Monitoring
class GatherLogsFirefoxTest {
static final Logger log = getLogger(lookup().lookupClass());
WebDriverManager wdm = WebDriverManager.firefoxdriver().watch();
WebDriver driver;
@BeforeEach
void setup() {
driver = wdm.create();
}
@AfterEach
void teardown() {
driver.quit();
}
@Test
void test() {
driver.get("https://bonigarcia.dev/selenium-webdriver-java/console-logs.html");
List<Map<String, Object>> logMessages = wdm.getLogs();
for (Map<String, Object> map : logMessages) {
log.debug("[{}] [{}] {}", map.get("datetime"),
String.format("%1$-14s",
map.get("source").toString().toUpperCase() + "."
+ map.get("type").toString().toUpperCase()),
map.get("message"));
} assertThat(logMessages).hasSize(5);
}
}
The method watch() allows to
install BrowserWatcher in the
browser controlled with Selenium
WebDriver. Then, it allows to gather
the browser logs (i.e., its console)
invoking the method getLogs()
3. The evolution: WebDriverManager 5
4. Monitoring class DisplayLogsChromeTest {
static final Logger log = getLogger(lookup().lookupClass());
WebDriverManager wdm = WebDriverManager.chromedriver().watchAndDisplay();
WebDriver driver;
@BeforeEach
void setup() {
driver = wdm.create();
}
@AfterEach
void teardown() throws InterruptedException {
// pause for manual browser inspection
Thread.sleep(Duration.ofSeconds(3).toMillis());
driver.quit();
}
@Test
void test() {
// test logic
}
}
The method
watchAndDisplay() allows
displaying the console logs as
dialog notifications on the page
3. The evolution: WebDriverManager 5
4. Monitoring class RecordEdgeTest {
WebDriver driver;
WebDriverManager wdm = WebDriverManager.edgedriver().watch();
@BeforeEach
void setup() {
driver = wdm.create();
}
@AfterEach
void teardown() {
driver.quit();
}
@Test
void test() throws InterruptedException {
driver.get(
"https://bonigarcia.dev/selenium-webdriver-java/slow-calculator.html");
wdm.startRecording(REC_FILENAME);
// test logic
wdm.stopRecording();
}
}
The methods
startRecording() and
stopRecording() allows
record the browser viewport
4. Beyond Java
• WebDriverManager can also be used as a:
1. CLI (command line interface) tool:
• Using the WebDriverManager fat-JAR:
• Using its source code and Maven:
• Using its Docker image:
java -jar webdrivermanager-5.2.2-fat.jar resolveDriverFor chrome
mvn exec:java -Dexec.args="resolveDriverFor chrome"
docker run --rm -v ${PWD}:/wdm -e ARGS="resolveDriverFor chrome" bonigarcia/webdrivermanager:5.2.2
java -jar webdrivermanager-5.2.2-fat.jar runInDocker chrome
mvn exec:java -Dexec.args="runInDocker chrome"
docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock -e ARGS="runInDocker chrome"
bonigarcia/webdrivermanager:5.2.2
The option
resolveDriverFor allows
to resolve drivers from the
shell
The option runInDocker
allows to execute browsers in
Docker containers and
interact with them using
noVNC
4. Beyond Java
• WebDriverManager can also be used as a:
2. Server:
- Using the WebDriverManager fat-JAR:
- Using its source code and Maven:
- Using its Docker image:
This server provides two features:
i. To resolve drivers using a REST-like API:
ii. As a Selenium Server (that uses Docker to manage the browser
infrastructure)
java -jar webdrivermanager-5.2.2-fat.jar server
mvn exec:java -Dexec.args="server"
docker run --rm -p 4444:4444 -v
/var/run/docker.sock:/var/run/docker.sock
bonigarcia/webdrivermanager:5.2.2
http://localhost:4444/chromedriver
http://localhost:4444/
http://localhost:4444/chromedriver?chromeVersion=100
5. Limitations of WebDriverManager
• WebDriverManager is mainly used from Java
- Although it has other usages (CLI, server), its main use is together the
Selenium WebDriver Java language binding
• Mobile Chrome (Android) in Docker requires hardware virtualization
• Docker browsers are not yet available on macOS ARM
• Monitoring capabilities through BrowserWatcher are not available
on headless browsers
- For log gathering, a fallback based on LoggingPreferences for Chrome
is implemented (WebDriver BiDi capabilities is pending to be implemented)
• Tab recording through BrowserWatcher only works in Chrome/Edge,
since this feature is based on the chrome.tabCapture API
6. Summary and outlook
• WebDriverManager is a helper tool for Selenium in Java
- It was born to carry out automated management (i.e., driver, setup,
and maintenance) of the drivers required by Selenium WebDriver
- As of version 5, it provides other features: browser finder,
WebDriver builder, browsers in Docker, and monitoring through
BrowserWatcher
6. Summary and outlook
• Currently, I am working in the proposal for the implementation
something similar to WebDriverManager, but as an official
component of the Selenium project: Selenium Manager (a.k.a.
batteries included)
WebDriverManager:
the Swiss Army Knife for
Selenium WebDriver
Thank you very much!
Q&A
Boni García
boni.garcia.c@saucelabs.com https://bonigarcia.dev
@boni_gg https://github.com/bonigarcia

Mais conteúdo relacionado

Semelhante a WebDriverManager: the Swiss Army Knife for Selenium WebDriver

Top 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdfTop 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdfAnanthReddy38
 
Selenium for Tester.pdf
Selenium for Tester.pdfSelenium for Tester.pdf
Selenium for Tester.pdfRTechRInfoIT
 
Getting started with Selenium 2
Getting started with Selenium 2Getting started with Selenium 2
Getting started with Selenium 2Sebastiano Armeli
 
前端網頁自動測試
前端網頁自動測試 前端網頁自動測試
前端網頁自動測試 政億 林
 
Selenium Java for Beginners by Sujit Pathak
Selenium Java for Beginners by Sujit PathakSelenium Java for Beginners by Sujit Pathak
Selenium Java for Beginners by Sujit PathakSoftware Testing Board
 
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...Edureka!
 
Introduction to Selenium and WebDriver
Introduction to Selenium and WebDriverIntroduction to Selenium and WebDriver
Introduction to Selenium and WebDriverTechWell
 
Complete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdfComplete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdframya9288
 
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptxA Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptxMatthew Allen
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introductionvstorm83
 
Getting up and running with selenium for automated Code palousa
Getting up and running with selenium for automated  Code palousaGetting up and running with selenium for automated  Code palousa
Getting up and running with selenium for automated Code palousaEmma Armstrong
 
Automated UI testing.Selenium.DrupalCamp Kyiv 2011
Automated UI testing.Selenium.DrupalCamp Kyiv 2011Automated UI testing.Selenium.DrupalCamp Kyiv 2011
Automated UI testing.Selenium.DrupalCamp Kyiv 2011camp_drupal_ua
 
Best java automation training institute in Bangalore - Selenium Labs
Best java automation training institute in Bangalore - Selenium Labs Best java automation training institute in Bangalore - Selenium Labs
Best java automation training institute in Bangalore - Selenium Labs Selenium Labs
 

Semelhante a WebDriverManager: the Swiss Army Knife for Selenium WebDriver (20)

Top 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdfTop 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
 
Selenium for Tester.pdf
Selenium for Tester.pdfSelenium for Tester.pdf
Selenium for Tester.pdf
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
Getting started with Selenium 2
Getting started with Selenium 2Getting started with Selenium 2
Getting started with Selenium 2
 
Web driver training
Web driver trainingWeb driver training
Web driver training
 
前端網頁自動測試
前端網頁自動測試 前端網頁自動測試
前端網頁自動測試
 
Selenium Java for Beginners by Sujit Pathak
Selenium Java for Beginners by Sujit PathakSelenium Java for Beginners by Sujit Pathak
Selenium Java for Beginners by Sujit Pathak
 
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
 
Introduction to Selenium and WebDriver
Introduction to Selenium and WebDriverIntroduction to Selenium and WebDriver
Introduction to Selenium and WebDriver
 
Selenium WebDriver FAQ's
Selenium WebDriver FAQ'sSelenium WebDriver FAQ's
Selenium WebDriver FAQ's
 
Selenium web driver
Selenium web driverSelenium web driver
Selenium web driver
 
Complete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdfComplete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdf
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptxA Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
A Definitive Guide to Mastering Selenium WebDriver Automation Effectively.pptx
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
 
Getting up and running with selenium for automated Code palousa
Getting up and running with selenium for automated  Code palousaGetting up and running with selenium for automated  Code palousa
Getting up and running with selenium for automated Code palousa
 
Selenium
SeleniumSelenium
Selenium
 
Protractor overview
Protractor overviewProtractor overview
Protractor overview
 
Automated UI testing.Selenium.DrupalCamp Kyiv 2011
Automated UI testing.Selenium.DrupalCamp Kyiv 2011Automated UI testing.Selenium.DrupalCamp Kyiv 2011
Automated UI testing.Selenium.DrupalCamp Kyiv 2011
 
Best java automation training institute in Bangalore - Selenium Labs
Best java automation training institute in Bangalore - Selenium Labs Best java automation training institute in Bangalore - Selenium Labs
Best java automation training institute in Bangalore - Selenium Labs
 

Mais de Boni García

Selenium Manager: Automated Driver & Browser Management for Selenium WebDriver
Selenium Manager: Automated Driver & Browser Management for Selenium WebDriverSelenium Manager: Automated Driver & Browser Management for Selenium WebDriver
Selenium Manager: Automated Driver & Browser Management for Selenium WebDriverBoni García
 
Developing Selenium tests with JUnit 5
Developing Selenium tests with JUnit 5Developing Selenium tests with JUnit 5
Developing Selenium tests with JUnit 5Boni García
 
Extending WebDriver: A cloud approach
Extending WebDriver: A cloud approachExtending WebDriver: A cloud approach
Extending WebDriver: A cloud approachBoni García
 
A Proposal to Orchestrate Test Cases
A Proposal to Orchestrate Test CasesA Proposal to Orchestrate Test Cases
A Proposal to Orchestrate Test CasesBoni García
 
Introducción y novedades de JUnit 5 (04/07/2018)
Introducción y novedades de JUnit 5 (04/07/2018)Introducción y novedades de JUnit 5 (04/07/2018)
Introducción y novedades de JUnit 5 (04/07/2018)Boni García
 
User Impersonation as a Service in End-to-End Testing
User Impersonation as a Service in End-to-End TestingUser Impersonation as a Service in End-to-End Testing
User Impersonation as a Service in End-to-End TestingBoni García
 
Introducción y novedades de JUnit 5 (16/01/2018)
Introducción y novedades de JUnit 5 (16/01/2018)Introducción y novedades de JUnit 5 (16/01/2018)
Introducción y novedades de JUnit 5 (16/01/2018)Boni García
 
WebRTC Testing: State of the Art
WebRTC Testing: State of the ArtWebRTC Testing: State of the Art
WebRTC Testing: State of the ArtBoni García
 
ElasTest: an elastic platform for testing complex distributed large software ...
ElasTest: an elastic platform for testing complex distributed large software ...ElasTest: an elastic platform for testing complex distributed large software ...
ElasTest: an elastic platform for testing complex distributed large software ...Boni García
 
Analysis of video quality and end-to-end latency in WebRTC
Analysis of video quality and end-to-end latency in WebRTCAnalysis of video quality and end-to-end latency in WebRTC
Analysis of video quality and end-to-end latency in WebRTCBoni García
 
NUBOMEDIA: an Elastic PaaS Enabling the Convergence of Real-Time and Big Data...
NUBOMEDIA: an Elastic PaaS Enabling the Convergence of Real-Time and Big Data...NUBOMEDIA: an Elastic PaaS Enabling the Convergence of Real-Time and Big Data...
NUBOMEDIA: an Elastic PaaS Enabling the Convergence of Real-Time and Big Data...Boni García
 
WebRTC/Kurento/NUBOMEDIA Hackathon at IETF’96
WebRTC/Kurento/NUBOMEDIA Hackathon at IETF’96WebRTC/Kurento/NUBOMEDIA Hackathon at IETF’96
WebRTC/Kurento/NUBOMEDIA Hackathon at IETF’96Boni García
 
Cloud Instances of Kurento v6 on FIWARE Lab
Cloud Instances of Kurento v6 on FIWARE LabCloud Instances of Kurento v6 on FIWARE Lab
Cloud Instances of Kurento v6 on FIWARE LabBoni García
 
Kurento v6 Development Guide
Kurento v6 Development GuideKurento v6 Development Guide
Kurento v6 Development GuideBoni García
 
Kurento v6 Installation Guide
Kurento v6 Installation GuideKurento v6 Installation Guide
Kurento v6 Installation GuideBoni García
 
Introduction to the Stream Oriented GE (Kurento v6)
Introduction to the Stream Oriented GE (Kurento v6)Introduction to the Stream Oriented GE (Kurento v6)
Introduction to the Stream Oriented GE (Kurento v6)Boni García
 

Mais de Boni García (17)

Selenium Manager: Automated Driver & Browser Management for Selenium WebDriver
Selenium Manager: Automated Driver & Browser Management for Selenium WebDriverSelenium Manager: Automated Driver & Browser Management for Selenium WebDriver
Selenium Manager: Automated Driver & Browser Management for Selenium WebDriver
 
Developing Selenium tests with JUnit 5
Developing Selenium tests with JUnit 5Developing Selenium tests with JUnit 5
Developing Selenium tests with JUnit 5
 
Extending WebDriver: A cloud approach
Extending WebDriver: A cloud approachExtending WebDriver: A cloud approach
Extending WebDriver: A cloud approach
 
A Proposal to Orchestrate Test Cases
A Proposal to Orchestrate Test CasesA Proposal to Orchestrate Test Cases
A Proposal to Orchestrate Test Cases
 
Introducción y novedades de JUnit 5 (04/07/2018)
Introducción y novedades de JUnit 5 (04/07/2018)Introducción y novedades de JUnit 5 (04/07/2018)
Introducción y novedades de JUnit 5 (04/07/2018)
 
User Impersonation as a Service in End-to-End Testing
User Impersonation as a Service in End-to-End TestingUser Impersonation as a Service in End-to-End Testing
User Impersonation as a Service in End-to-End Testing
 
Introducción y novedades de JUnit 5 (16/01/2018)
Introducción y novedades de JUnit 5 (16/01/2018)Introducción y novedades de JUnit 5 (16/01/2018)
Introducción y novedades de JUnit 5 (16/01/2018)
 
WebRTC Testing: State of the Art
WebRTC Testing: State of the ArtWebRTC Testing: State of the Art
WebRTC Testing: State of the Art
 
ElasTest: an elastic platform for testing complex distributed large software ...
ElasTest: an elastic platform for testing complex distributed large software ...ElasTest: an elastic platform for testing complex distributed large software ...
ElasTest: an elastic platform for testing complex distributed large software ...
 
Analysis of video quality and end-to-end latency in WebRTC
Analysis of video quality and end-to-end latency in WebRTCAnalysis of video quality and end-to-end latency in WebRTC
Analysis of video quality and end-to-end latency in WebRTC
 
NUBOMEDIA: an Elastic PaaS Enabling the Convergence of Real-Time and Big Data...
NUBOMEDIA: an Elastic PaaS Enabling the Convergence of Real-Time and Big Data...NUBOMEDIA: an Elastic PaaS Enabling the Convergence of Real-Time and Big Data...
NUBOMEDIA: an Elastic PaaS Enabling the Convergence of Real-Time and Big Data...
 
NUBOMEDIA Webinar
NUBOMEDIA WebinarNUBOMEDIA Webinar
NUBOMEDIA Webinar
 
WebRTC/Kurento/NUBOMEDIA Hackathon at IETF’96
WebRTC/Kurento/NUBOMEDIA Hackathon at IETF’96WebRTC/Kurento/NUBOMEDIA Hackathon at IETF’96
WebRTC/Kurento/NUBOMEDIA Hackathon at IETF’96
 
Cloud Instances of Kurento v6 on FIWARE Lab
Cloud Instances of Kurento v6 on FIWARE LabCloud Instances of Kurento v6 on FIWARE Lab
Cloud Instances of Kurento v6 on FIWARE Lab
 
Kurento v6 Development Guide
Kurento v6 Development GuideKurento v6 Development Guide
Kurento v6 Development Guide
 
Kurento v6 Installation Guide
Kurento v6 Installation GuideKurento v6 Installation Guide
Kurento v6 Installation Guide
 
Introduction to the Stream Oriented GE (Kurento v6)
Introduction to the Stream Oriented GE (Kurento v6)Introduction to the Stream Oriented GE (Kurento v6)
Introduction to the Stream Oriented GE (Kurento v6)
 

Último

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 

Último (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 

WebDriverManager: the Swiss Army Knife for Selenium WebDriver

  • 1. WebDriverManager: the Swiss Army Knife for Selenium WebDriver Selenium Conference 2022 July 29, 2022 Boni García boni.garcia.c@saucelabs.com https://bonigarcia.dev @boni_gg https://github.com/bonigarcia
  • 2. Presentation Automated driver management and other helper features for Selenium WebDriver in Java Source code: https://github.com/bonigarcia/webdrivermanager Doc: https://bonigarcia.dev/webdrivermanager/
  • 3. 1. The little history of WebDriverManager 2004 Jason Huggins and Paul Hammant created Selenium core and RC (Selenium 1) 2007 2009 PhD candidate at UPM, focused on software quality and test automation for web applications. I used Selenium RC for my dissertation 2011 2013 Post-doc researcher at URJC. I used Selenium WebDriver for assessing WebRTC apps 2014 Private University Professor at U-tad. I gave a course about web programming 2007 2015 1.0.0 2018 Visiting Professor at UC3M Author of Packt book about JUnit 5 2021 2020 2017 2.0.0 2018 3.0.0 2020 4.0.0 5.0.0 2016 Selenium 3 Selenium 4 2021 2017 Author of O’Reilly book about Selenium 4 PhD 2021 2022 Staff Software Engineer at Sauce Labs Simon Stewart created WebDriver Huggins and Stewart merged Selenium and WebDriver into Selenium WebDriver (Selenium 2) 2019 W3C WebDriver 2020 W3C WebDriver BiDi Assistant Professor at URJC 2015
  • 4. 2. The original motivation: automated driver management • Selenium WebDriver (i.e. Selenium 2+) uses the native capabilities of each browser to support the automation
  • 5. 2. The original motivation: automated driver management • For a given browser (e.g. Chrome), I called driver management to the process of resolving its proper driver (e.g., chromedriver), and it is composed of three steps: 1. Download 2. Setup 3. Maintenance
  • 6. 2. The original motivation: automated driver management • Regarding the setup: - Once the driver is downloaded, to be used by Selenium WebDriver, it needs to be available in the PATH environment variable - Alternatively, the driver path needs to be exported using a given property before creating a WebDriver object System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver"); System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver"); System.setProperty("webdriver.edge.driver", "/path/to/msedgedriver"); System.setProperty("webdriver.opera.driver", "/path/to/operadriver"); System.setProperty("webdriver.ie.driver", "C:/path/to/IEDriverServer.exe");
  • 7. 2. The original motivation: automated driver management • Regarding the maintenance: - Modern web browsers are evergreen (i.e., they automatically and silently upgrade to the next stable version) - Due to this upgrade, the driver-browser compatibility is not satisfied in the long run chromedriver 98.0.4758.102 Chrome 98 … chromedriver 98.0.4758.102 Chrome 99 … chromedriver 98.0.4758.102 Chrome 100 this version of chromedriver only supports Chrome version N
  • 8. 2. The original motivation: automated driver management
  • 9. 2. The original motivation: automated driver management • WebDriverManager is an open-source Java library that carries out the management (i.e., download, setup, and maintenance) of the drivers required by Selenium WebDriver (e.g., chromedriver, geckodriver, msedgedriver, etc.) in a fully automated manner. WebDriverManager.chromedriver().setup(); WebDriverManager.firefoxdriver().setup(); WebDriverManager.edgedriver().setup(); WebDriverManager.chromiumdriver().setup(); WebDriverManager.operadriver().setup(); WebDriverManager.iedriver().setup(); <dependency> <groupId>io.github.bonigarcia</groupId> <artifactId>webdrivermanager</artifactId> <version>5.2.2</version> <scope>test</scope> </dependency> dependencies { testImplementation("io.github.bonigarcia:webdrivermanager:5.2.2") }
  • 10. 2. The original motivation: automated driver management class ChromeTest { WebDriver driver; @BeforeAll static void setupClass() { WebDriverManager.chromedriver().setup(); } @BeforeEach void setup() { driver = new ChromeDriver(); } @AfterEach void teardown() { driver.quit(); } @Test public void test() { // Your test logic here } } public class FirefoxTest { private WebDriver driver; @BeforeClass public static void setupClass() { WebDriverManager.firefoxdriver().setup(); } @BeforeMethod public void setup() { driver = new FirefoxDriver(); } @AfterMethod public void teardown() { driver.quit(); } @Test public void test() { // Your test logic here } } + +
  • 11. 2. The original motivation: automated driver management @ExtendWith(SeleniumJupiter.class) class HelloWorldChromeSelJupTest { @Test void test(ChromeDriver driver) { // Your test logic here } } + JUnit 5 extension for Selenium WebDriver Source code: https://github.com/bonigarcia/selenium-jupiter Doc: https://bonigarcia.dev/selenium-jupiter/
  • 12. 2. The original motivation: automated driver management • WebDriverManager was first released on 21st March 2015 • In its earlier versions, WebDriverManager downloaded the latest version of the driver by default Check driver latest version Driver in cache? Download driver Export driver path Driver cache no Driver repository (online) yes setup()
  • 13. 2. The original motivation: automated driver management • Currently, WebDriverManager resolution algorithm is much richer García, Boni, et al. "Automated driver management for Selenium WebDriver." Empirical Software Engineering (2021)
  • 14. 2. The original motivation: automated driver management • WebDriverManager exposes a rich fluent API, e.g.: • WebDriverManager is highly configurable with: 1. Java properties, e.g.: 2. Environment variables, e.g.: WebDriverManager.chromedriver().browserVersion("99").setup(); WebDriverManager.firefoxdriver().arch32().setup(); WebDriverManager.operadriver().forceDownload().setup(); WebDriverManager.edgedriver().proxy("server:port").setup(); Force a chromedriver version compatible with Chrome 99 Force 32-bit architecture for geckodriver Force the download of operadriver (even if it is in the cached) Set proxy setup when managing msedgedriver https://bonigarcia.dev/webdrivermanager/ mvn test -Dwdm.cachePath=~/.selenium export WDM_CACHEPATH=~/.selenium
  • 15. 3. The evolution: WebDriverManager 5 • WebDriverManager 5 was released on August 30, 2021 - As of this version, WebDriverManager provides other features than automated driver management for Selenium WebDriver Source code: https://github.com/bonigarcia/selenium-webdriver-java Practice site: https://bonigarcia.dev/selenium-webdriver-java/ O’Reilly will give three e-books as a giveaway to the participants in the following survey about the challenges and solutions of Selenium WebDriver: https://forms.gle/QzsSpJD5R2bGx2ZZ7
  • 16. 3. The evolution: WebDriverManager 5 1. Browser finder class SafariTest { WebDriver driver; @BeforeAll static void setupClass() { Optional<Path> browserPath = WebDriverManager.safaridriver() .getBrowserPath(); assumeThat(browserPath).isPresent(); } @BeforeEach void setupTest() { driver = new SafariDriver(); } @AfterEach void teardown() { driver.quit(); } @Test void test() { driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); assertThat(driver.getTitle()).contains("Selenium WebDriver"); } } WebDriverManager provides the method getBrowserPath() to find out if the browser is installed or not
  • 17. 3. The evolution: WebDriverManager 5 2. WebDriver builder class ChromeCreateTest { WebDriver driver; @BeforeEach void setupTest() { driver = WebDriverManager.chromedriver().create(); } @AfterEach void teardown() { driver.quit(); } @Test void test() { driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); assertThat(driver.getTitle()).contains("Selenium WebDriver"); } } WebDriverManager provides the method create() to instantiate WebDriver objects (e.g., ChromeDriver, FirefoxDriver, etc.)
  • 18. 3. The evolution: WebDriverManager 5 3. Browsers in Docker class DockerChromeTest { WebDriver driver; WebDriverManager wdm = WebDriverManager.chromedriver().browserInDocker(); @BeforeEach void setupTest() { driver = wdm.create(); } @AfterEach void teardown() { wdm.quit(); } @Test void test() { driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); assertThat(driver.getTitle()).contains("Selenium WebDriver"); } } WebDriverManager provides the method browserInDocker() to control browsers in Docker containers https://aerokube.com/images/latest/
  • 19. 3. The evolution: WebDriverManager 5 3. Browsers in Docker class DockerChromeVncTest { WebDriver driver; WebDriverManager wdm = WebDriverManager.chromedriver().browserInDocker() .enableVnc(); @BeforeEach void setupTest() { driver = wdm.create(); } @AfterEach void teardown() { wdm.quit(); } @Test void test() throws Exception { driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); assertThat(driver.getTitle()).contains("Selenium WebDriver"); } } The method enableVnc() allows to connect to the remote desktop using VNC and noVNC The method enableRecording() allows recoding the remote session using FFmpeg
  • 20. 3. The evolution: WebDriverManager 5 3. Browsers in Docker class DockerChromeBetaTest { WebDriver driver; WebDriverManager wdm = WebDriverManager.chromedriver().browserInDocker() .browserVersion("beta"); @BeforeEach void setupTest() { assumeThat(isDockerAvailable()).isTrue(); driver = wdm.create(); } @AfterEach void teardown() { wdm.quit(); } @Test void test() { driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); assertThat(driver.getTitle()).contains("Selenium WebDriver"); } } The method browserVersion() allows to change the version of the dockerized browser. This version can be fixed (e.g., "100"), or the following wildcards: "latest" or "latest-N". Also: "beta" and "dev" (for Chrome and Firefox) WebDriverManager provides the static method isDockerAvailable() to check if there is a Docker engine installed on the local machine
  • 21. 3. The evolution: WebDriverManager 5 4. Monitoring • WebDriverManager 5.2.0 provides seamless integration with BrowserWatcher Source code: https://github.com/bonigarcia/browserwatcher Doc: https://bonigarcia.dev/browserwatcher/ Browser extension for console monitoring, tab recording, Content Security Policy (CSP) disabling, and JavaScript/CSS injection
  • 22. 3. The evolution: WebDriverManager 5 4. Monitoring class GatherLogsFirefoxTest { static final Logger log = getLogger(lookup().lookupClass()); WebDriverManager wdm = WebDriverManager.firefoxdriver().watch(); WebDriver driver; @BeforeEach void setup() { driver = wdm.create(); } @AfterEach void teardown() { driver.quit(); } @Test void test() { driver.get("https://bonigarcia.dev/selenium-webdriver-java/console-logs.html"); List<Map<String, Object>> logMessages = wdm.getLogs(); for (Map<String, Object> map : logMessages) { log.debug("[{}] [{}] {}", map.get("datetime"), String.format("%1$-14s", map.get("source").toString().toUpperCase() + "." + map.get("type").toString().toUpperCase()), map.get("message")); } assertThat(logMessages).hasSize(5); } } The method watch() allows to install BrowserWatcher in the browser controlled with Selenium WebDriver. Then, it allows to gather the browser logs (i.e., its console) invoking the method getLogs()
  • 23. 3. The evolution: WebDriverManager 5 4. Monitoring class DisplayLogsChromeTest { static final Logger log = getLogger(lookup().lookupClass()); WebDriverManager wdm = WebDriverManager.chromedriver().watchAndDisplay(); WebDriver driver; @BeforeEach void setup() { driver = wdm.create(); } @AfterEach void teardown() throws InterruptedException { // pause for manual browser inspection Thread.sleep(Duration.ofSeconds(3).toMillis()); driver.quit(); } @Test void test() { // test logic } } The method watchAndDisplay() allows displaying the console logs as dialog notifications on the page
  • 24. 3. The evolution: WebDriverManager 5 4. Monitoring class RecordEdgeTest { WebDriver driver; WebDriverManager wdm = WebDriverManager.edgedriver().watch(); @BeforeEach void setup() { driver = wdm.create(); } @AfterEach void teardown() { driver.quit(); } @Test void test() throws InterruptedException { driver.get( "https://bonigarcia.dev/selenium-webdriver-java/slow-calculator.html"); wdm.startRecording(REC_FILENAME); // test logic wdm.stopRecording(); } } The methods startRecording() and stopRecording() allows record the browser viewport
  • 25. 4. Beyond Java • WebDriverManager can also be used as a: 1. CLI (command line interface) tool: • Using the WebDriverManager fat-JAR: • Using its source code and Maven: • Using its Docker image: java -jar webdrivermanager-5.2.2-fat.jar resolveDriverFor chrome mvn exec:java -Dexec.args="resolveDriverFor chrome" docker run --rm -v ${PWD}:/wdm -e ARGS="resolveDriverFor chrome" bonigarcia/webdrivermanager:5.2.2 java -jar webdrivermanager-5.2.2-fat.jar runInDocker chrome mvn exec:java -Dexec.args="runInDocker chrome" docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock -e ARGS="runInDocker chrome" bonigarcia/webdrivermanager:5.2.2 The option resolveDriverFor allows to resolve drivers from the shell The option runInDocker allows to execute browsers in Docker containers and interact with them using noVNC
  • 26. 4. Beyond Java • WebDriverManager can also be used as a: 2. Server: - Using the WebDriverManager fat-JAR: - Using its source code and Maven: - Using its Docker image: This server provides two features: i. To resolve drivers using a REST-like API: ii. As a Selenium Server (that uses Docker to manage the browser infrastructure) java -jar webdrivermanager-5.2.2-fat.jar server mvn exec:java -Dexec.args="server" docker run --rm -p 4444:4444 -v /var/run/docker.sock:/var/run/docker.sock bonigarcia/webdrivermanager:5.2.2 http://localhost:4444/chromedriver http://localhost:4444/ http://localhost:4444/chromedriver?chromeVersion=100
  • 27. 5. Limitations of WebDriverManager • WebDriverManager is mainly used from Java - Although it has other usages (CLI, server), its main use is together the Selenium WebDriver Java language binding • Mobile Chrome (Android) in Docker requires hardware virtualization • Docker browsers are not yet available on macOS ARM • Monitoring capabilities through BrowserWatcher are not available on headless browsers - For log gathering, a fallback based on LoggingPreferences for Chrome is implemented (WebDriver BiDi capabilities is pending to be implemented) • Tab recording through BrowserWatcher only works in Chrome/Edge, since this feature is based on the chrome.tabCapture API
  • 28. 6. Summary and outlook • WebDriverManager is a helper tool for Selenium in Java - It was born to carry out automated management (i.e., driver, setup, and maintenance) of the drivers required by Selenium WebDriver - As of version 5, it provides other features: browser finder, WebDriver builder, browsers in Docker, and monitoring through BrowserWatcher
  • 29. 6. Summary and outlook • Currently, I am working in the proposal for the implementation something similar to WebDriverManager, but as an official component of the Selenium project: Selenium Manager (a.k.a. batteries included)
  • 30. WebDriverManager: the Swiss Army Knife for Selenium WebDriver Thank you very much! Q&A Boni García boni.garcia.c@saucelabs.com https://bonigarcia.dev @boni_gg https://github.com/bonigarcia