Slide 1

Slide 1 text

Modern UI Test Automation with Selenium Libraries Yuriy Artamonov

Slide 2

Slide 2 text

Author @Yuriy_Artamonov ■ Developing libraries, frameworks, and tools for developers for the past 10 years ■ Sad about their imperfect IDE support ■ Working in IntelliJ IDEA team on Selenium UI Testing plugin. 2

Slide 3

Slide 3 text

Topics — 1.Setting up Selenium and WebDriver 2.Running code 3.Modern APIs on top of Selenium 4.Reporting Libraries 5.Running Selenium on CI 6.Tooling and helpful resources 3

Slide 4

Slide 4 text

Statistics — https://www.jetbrains.com/lp/devecosystem-2020/testing/ 4

Slide 5

Slide 5 text

Java is Here! — https://www.jetbrains.com/lp/devecosystem-2020/testing/ 5

Slide 6

Slide 6 text

Selenium Basics — Selenium is: 1. Ecosystem of UI testing tools 2. User-agent library 3. Contiuous integration tools 6

Slide 7

Slide 7 text

Getting Started — 1. Install Selenium plugin for IntelliJ IDEA 2. Create a new project 3. Write tests! 7

Slide 8

Slide 8 text

Setting up Driver Binary — 1. Download webdriver binary, compatible with a local browser 2. Specify path to webdriver binary in tests: System.setProperty(“webdriver.chrome.driver”, “/path/to/binary/chromedriver”); No way! We can do this better with WebDriverManager: io.github.bonigarcia:webdrivermanager:4.4.3 Must-have library for managing drivers! 8

Slide 9

Slide 9 text

Modern APIs on top of Selenium — Top 3 productive APIs to write your UI tests: 1.Selenide (Java/Kotlin/Groovy) 2.FluentLenium (Java/Groovy) 3.Geb (Groovy) 9

Slide 10

Slide 10 text

Selenide — 1.Concise fluent APIs 2.AJAX support 3.Powerful selectors 4.Simple configuration 5. WebDriverManager Out-of-the-box See github.com/jreznot/intellij-selenide-example 10

Slide 11

Slide 11 text

Page Object Pattern — Main advantages: 1. Separate tests from page specific code 2. Single repository for operations offered by the page 11

Slide 12

Slide 12 text

Kotlin for UI Testing — Most useful Kotlin features for UI testing: 1.Extension functions 2.DSLs: let{}, apply{}, with{} 3.Type inference and implicit casts 4.Null-safety 5.Data classes 6.String templates 12

Slide 13

Slide 13 text

Reporting Libraries — Put your tests in order with reporting library: 1.Allure Framework 2.Serenity BDD 13

Slide 14

Slide 14 text

Mobile Testing — You can still use Java for mobile testing with: 1.Appium 2.Selenide with Appium 14

Slide 15

Slide 15 text

Running Selenium on CI Server — 1.Web browser on a host 2.Selenium Grid v3 or v4 3.Selenoid 4.Cloud Services 15

Slide 16

Slide 16 text

Selenoid — 1. Enables you to run web browsers in Docker 2. Implements Selenium Hub protocol 3. Easy to install 4. Easy to share browsers setup with browsers.json config 16

Slide 17

Slide 17 text

Running Test with Selenoid — Start Selenoid in Docker: https://hub.docker.com/u/selenoid > docker run -d \ --name selenoid \ -p 4444:4444 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /your/directory/config/:/etc/selenoid/:ro \ aerokube/selenoid:latest-release Selenide: Configuration.remote = "http://localhost:4444/wd/hub"; 17

Slide 18

Slide 18 text

Selenoid UI — Provides status pages and VNC access to running web browsers under test. > docker run -d --name=selenoid-ui --link selenoid -p 8080:8080 aerokube/selenoid-ui --selenoid-uri http://selenoid:4444 18

Slide 19

Slide 19 text

Perfect UI Automation Stack — ⬠ Java/Kotlin ⬠ Gradle ⬠ Selenide ⬠ Allure Framework ⬠ Selenoid No more custom frameworks needed! 19

Slide 20

Slide 20 text

Useful Resources — ● Selenium Guides: www.selenium.dev/documentation ● WebDriverManager: github.com/bonigarcia/webdrivermanager ● Selenide: selenide.org ● Allure Framework: github.com/allure-framework ● Selenoid: aerokube.com/selenoid ● Selenium UI Testing Plugin for IntelliJ IDEA: plugins.jetbrains.com/plugin/13691-selenium-ui-testing