Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

QA Fest 2019. Boni Garcia. Web and Mobile testing with Selenium, JUnit 5, and Docker

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio

Eche un vistazo a continuación

1 de 28 Anuncio

QA Fest 2019. Boni Garcia. Web and Mobile testing with Selenium, JUnit 5, and Docker

Selenium has become the de facto standard framework for end-to-end web testing nowadays. It allows to drive programmatically web browsers, such as Chrome, Firefox, etc. This talk presents Selenium-Jupiter (https://github.com/bonigarcia/selenium-jupiter), an open-source JUnit 5 extension aimed to provide seamless integration with Selenium and Appium. JUnit is the most popular test frameworks for Java and one of the most influential in software engineering. JUnit 5 is the next generation of JUnit, providing a brand-new programming and extension model called Jupiter. Selenium-Jupiter is a JUnit 5 extension to use Selenium and provides a rich variety of features, including the capability to use of local or remote browsers. Moreover, it allows to use browsers and Android devices in Docker containers out of the box. Selenium-Jupiter can be used to carry out different types of test of web applications, including functional, compatibility (i.e. using different browsers types and versions) or performance (i.e. using a big number of browsers) tests.

Selenium has become the de facto standard framework for end-to-end web testing nowadays. It allows to drive programmatically web browsers, such as Chrome, Firefox, etc. This talk presents Selenium-Jupiter (https://github.com/bonigarcia/selenium-jupiter), an open-source JUnit 5 extension aimed to provide seamless integration with Selenium and Appium. JUnit is the most popular test frameworks for Java and one of the most influential in software engineering. JUnit 5 is the next generation of JUnit, providing a brand-new programming and extension model called Jupiter. Selenium-Jupiter is a JUnit 5 extension to use Selenium and provides a rich variety of features, including the capability to use of local or remote browsers. Moreover, it allows to use browsers and Android devices in Docker containers out of the box. Selenium-Jupiter can be used to carry out different types of test of web applications, including functional, compatibility (i.e. using different browsers types and versions) or performance (i.e. using a big number of browsers) tests.

Anuncio
Anuncio

Más Contenido Relacionado

Presentaciones para usted (20)

Similares a QA Fest 2019. Boni Garcia. Web and Mobile testing with Selenium, JUnit 5, and Docker (20)

Anuncio

Más de QAFest (20)

Más reciente (20)

Anuncio

QA Fest 2019. Boni Garcia. Web and Mobile testing with Selenium, JUnit 5, and Docker

  1. 1. Тема доклада Тема доклада Тема доклада KYIV 2019 Web and Mobile Testing with Selenium,JUnit 5,and Docker QA CONFERENCE#1 IN UKRAINE Boni García boni.garcia@urjc.es
  2. 2. Web and Mobile Testing with Selenium, JUnit 5, and Docker Boni García QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Assistant Professor at KingJuan CarlosUniversity (URJC) in Spain ● Author of 35+ research papersin different journals, magazines,international conferences,and the book MasteringSoftware Testingwith JUnit 5 ● Maintainer of different open source projects,such as WebDriverManager,Selenium-Jupiter,or DualSub 2 http://bonigarcia.github.io/
  3. 3. Web and Mobile Testing with Selenium, JUnit 5, and Docker Table of contents QA CONFERENCE#1 IN UKRAINE KYIV 2019 1. Background • Selenium • JUnit • Docker 2. Selenium-Jupiter 3. Final remarksand future work 3
  4. 4. Web and Mobile Testing with Selenium, JUnit 5, and Docker 1.Background - Selenium QA CONFERENCE#1 IN UKRAINE KYIV 2019 4 Selenium bindings ... Browsers JSON Wire protocol / W3C WebDriver Browser specific calls Browser drivers chromedriver geckodriver msedgedriver ... operadriver ... ● Selenium isafamily of projectsfor automated testingwith browsers ○ WebDriver allowsto control web browsersprogrammatically https://seleniumhq.github.io/docs/site/en/webdriver/
  5. 5. Web and Mobile Testing with Selenium, JUnit 5, and Docker 1.Background - Selenium QA CONFERENCE#1 IN UKRAINE KYIV 2019 5 Selenium bindings ... Node 1 (Chrome) Hub (Selenium Server) chromedriver Node 2 (Firefox) geckodriver Node N (Edge) msedgedriver ... https://seleniumhq.github.io/docs/site/en/grid/ ○ Grid allowsto drive web browsersin parallel hosted on remote machines: JSON Wire protocol / W3C WebDriver JSON Wire protocol / W3C WebDriver
  6. 6. Web and Mobile Testing with Selenium, JUnit 5, and Docker 1.Background - JUnit QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● JUnit isthe most popular testingframework for Java and can be used to implement different typesof tests(unit,integration,end-to-end,…) ● JUnit 5 (first GA released on September 2017) providesabrand-new programmingan extension model called Jupiter https://junit.org/junit5/docs/current/user-guide/ 6
  7. 7. Web and Mobile Testing with Selenium, JUnit 5, and Docker 1.Background - JUnit QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● The extension model of Jupiter allowsto add custom featuresto the programmingmodel: ○ Dependency injection in test methodsand constructors ○ Custom logic in the test lifecycle ○ Test templates 7 Very convenient for Selenium!
  8. 8. Web and Mobile Testing with Selenium, JUnit 5, and Docker 1.Background - Docker QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Docker isasoftware technology which allowsto pack and run any application as alightweight and portablecontainer ● The Docker platform hastwo main components: the Docker Engine,to create and execute containers;and the Docker Hub (https://hub.docker.com/),acloud service for distributingcontainers 8 https://www.docker.com/
  9. 9. Web and Mobile Testing with Selenium, JUnit 5, and Docker Table of contents QA CONFERENCE#1 IN UKRAINE KYIV 2019 1. Background 2. Selenium-Jupiter • Motivation • Setup • Local browsers • Remote browsers • Docker browsers • Test templates • Integration with Jenkins • Beyond Java 3. Final remarksand future work 9
  10. 10. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Motivation QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Selenium-Jupiter isaJUnit 5 extension aimed to ease the use of Selenium and Appium from Javatests 10 https://bonigarcia.github.io/selenium-jupiter/ Clean test code (reduced boilerplate) EffortlessDocker integration (web browsersand Android devices) Advanced featuresfor tests
  11. 11. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Setup QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Selenium-Jupiter can be included in aJavaproject asfollows: 11 <dependency> <groupId>io.github.bonigarcia</groupId> <artifactId>selenium-jupiter</artifactId> <version>3.3.1</version> <scope>test</scope> </dependency> dependencies { testCompile("io.github.bonigarcia:selenium-jupiter:3.3.1") } Usingthe latest version is always recommended!
  12. 12. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Setup QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Source code: https://github.com/bonigarcia/selenium-jupiter ● Documentation: https://bonigarcia.github.io/selenium-jupiter/ ● Examples: https://github.com/bonigarcia/selenium-jupiter-examples 12 Requirementsto run these examples: • Java • Maven/Gradle (alternatively some IDE) • Docker Engine • Linux (only required when running Android in Docker)
  13. 13. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Local browsers QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● JUnit 4 and Selenium JUnit 5 and Selenium-Jupiter: 13
  14. 14. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Local browsers QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Selenium-Jupiter usesJUnit 5’s dependency injection 14 @ExtendWith(SeleniumExtension.class) class SeleniumJupiterTest { @Test void test(ChromeDriver chromeDriver) { // Use Chrome in this test } } Valid types: ChromeDriver, FirefoxDriver, OperaDriver, SafariDriver, EdgeDriver, InternetExplorerDriver, HtmlUnitDriver, PhantomJSDriver, AppiumDriver, SelenideDriver
  15. 15. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Local browsers QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Seamlessintegration with Selenide (fluent API for Selenium in Java) 15 @ExtendWith(SeleniumExtension.class) class SelenideDefaultTest { @Test void testWithSelenideAndChrome(SelenideDriver driver) { driver.open( "https://bonigarcia.github.io/selenium-jupiter/"); SelenideElement about = driver.$(linkText("About")); about.shouldBe(visible); about.click(); } }https://selenide.org/
  16. 16. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Local browsers QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Use case: WebRTCapplications(real-time communicationsusingweb browsers) ○ We need to specify optionsfor browsers: 16
  17. 17. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Local browsers QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Use case: reuse same browser by different tests ○ Convenient for ordered tests(JUnit 5 new feature) 17
  18. 18. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Remote browsers QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Selenium-Jupiter providesthe annotations@DriverUrl and @DriverCapabilities to control remote browsers and mobiles, e.g.: 18 https://saucelabs.com/ http://appium.io/
  19. 19. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Docker browsers QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Selenium-Jupiter providesseamlessintegration with Docker using the annotation @DockerBrowser: ○ Chrome, Firefox, and Opera: ■ Docker images for stable versions are maintained by Aerokube ■ Beta and unstable (Chrome and Firefox) are maintained by ElasTest ○ Edge and Internet Explorer: ■ Due to license, these Docker images are not hosted in Docker Hub ■ It can be built following a tutorial provided by Aerokube ○ Android devices: ■ Docker images for Android (docker-android project) by Budi Utomo 19
  20. 20. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Docker browsers QA CONFERENCE#1 IN UKRAINE KYIV 2019 20 @ExtendWith(SeleniumExtension.class) class DockerBasicTest { @Test void testFirefoxBeta( @DockerBrowser(type = FIREFOX, version = "beta") RemoteWebDriver driver) { driver.get("https://bonigarcia.github.io/selenium-jupiter/"); assertThat(driver.getTitle(), containsString("JUnit 5 extension for Selenium")); } } Supported browser types are: CHROME, FIREFOX, OPERA, EDGE , IEXPLORER and ANDROID If version is not specified, the latest container version in Docker Hub is pulled. This parameter allows fixed versions and also the special values: latest, latest-*, beta, and unstable
  21. 21. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Docker browsers QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● The use of Docker enablesarich number of features: ○ Remote session accesswith VNC ○ Session recordings ○ Performance tests 21
  22. 22. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Docker browsers QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● The possibleAndroid setup optionsare the following: 22 Android version API level Browser name 5.0.1 21 browser 5.1.1 22 browser 6.0 23 chrome 7.0 24 chrome 7.1.1 25 chrome 8.0 26 chrome 8.1 27 chrome 9.0 28 chrome Type Device name Phone SamsungGalaxy S6 Phone Nexus4 Phone Nexus5 Phone NexusOne Phone NexusS Tablet Nexus7
  23. 23. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Test templates QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Selenium-Jupiter use the JUnit 5’ssupport for test templates 23 @ExtendWith(SeleniumExtension.class) public class TemplateTest { @TestTemplate void templateTest(WebDriver driver) { // test } }
  24. 24. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Integration with Jenkins QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Seamlessintegration with Jenkins through the Jenkinsattachment plugin ● It allowsto attach output filesin tests (e.g.PNGscreenshotsand MP4 recordings)in the JenkinsGUI ● For example: 24 $ mvn clean test -Dtest=DockerRecordingTest -Dsel.jup.recording=true -Dsel.jup.screenshot.at.the.end.of.tests=true -Dsel.jup.screenshot.format=png -Dsel.jup.output.folder=surefire-reports
  25. 25. Web and Mobile Testing with Selenium, JUnit 5, and Docker 2.Selenium-Jupiter - Beyond Java QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Selenium-Jupiter can be also used: 1. AsCLI (Command Line Interface) tool: 2. Asaserver (usingaREST-like API): 25 $ java -jar selenium-jupiter-3.3.1-fat.jar chrome unstable [INFO] Using Selenium-Jupiter to execute chrome unstable in Docker ... Selenium-Jupiter allows to control Docker browsers through VNC (manual testing) $ java -jar webdrivermanager-3.3.1-fat.jar server [INFO] Selenium-Jupiter server listening on http://localhost:4042/wd/hub Selenium-Jupiter becomes into a Selenium Server (Hub)
  26. 26. Web and Mobile Testing with Selenium, JUnit 5, and Docker Table of contents QA CONFERENCE#1 IN UKRAINE KYIV 2019 1. Background 2. Selenium-Jupiter 3. Final remarksand future work 26
  27. 27. Web and Mobile Testing with Selenium, JUnit 5, and Docker 3.Final remarksand future work QA CONFERENCE#1 IN UKRAINE KYIV 2019 ● Selenium-Jupiter hasanother featuressuch as: ○ Configurable screenshotsat the end of test (asPNG image or Base64) ○ Integration with Genymotion (cloud provider for Android devices) ○ Generic driver (configurable type of browser) ○ Mappingvolumesin Docker containers ○ Accessto Docker client to manage custom containers ● Selenium-Jupiter isin constant development.Itsroadmap includes: ○ Implement a browser console (JavaScript log) gathering mechanism ○ Improve test template support (e.g.specifyingoptions) ○ Improve scalability for performance tests(e.g.using Kubernetes) 27
  28. 28. Тема доклада Тема доклада Тема доклада KYIV 2019 Web and Mobile Testing with Selenium,JUnit 5,and Docker QA CONFERENCE#1 IN UKRAINE Thank you very much! Boni García boni.garcia@urjc.es

×