SlideShare a Scribd company logo
1 of 42
DSL, Page Object and Selenium – a way to reliable functional tests  Mikalai Alimenkou http://xpinjection.com 26.02.2011
Background Java Technical Lead/Scrum Master at Zoral Labs 6+ years in software development 4+ years of working by Agile methodologies Expert in Agile engineering practices Agile coach (TDD, Testing, Planning, etc.)at XP Injection (http://xpinjection.com)
Agenda Selenium tests issues Step 1: DSL introduction Step 2: Page Object pattern Step 3: Page Element pattern Results analysis
Selenium TESTS Issues When you have a hammer, everything looks like a nail
Test Components Application Driver Test Data Test Logic
How Selenium Works? Get Browser InvokeCommands Provide Data Use Locators
Selenium Tests Issues: Verbose xpath=//input[@value=‘continue’] browser.enter… browser.click… css=#results dip p.first browser.getXpathCount… id=greenButton browser.waitForPageToLoad… browser.check…
Selenium Tests Issues: Not Expressive
Selenium Tests Issues: Unreadable
Selenium Tests Issues: Fragile browser.click("//input[@id=(//label[text()='Fax']/@for)] "); What is going on here? browser.getText(“//div[@id='App']/div/p[4]/div[1]/h4[@class='Online']”); Depends too much on page structure!
Even More Hidden Issues
What is the Primary Goal? To enable reliable stable tests we need to separate all parts as much as possible
Ideal Testing Framework Test Data Storage Technical Data Storage
Step 1: Introduce DSL Create domain-specific language for your application
Definition of DSL A domain-specific language (DSL) is a programming language or specification language dedicated to a particular problem domain, that is created specifically to solveproblems in this particular domain and is not intended to be able to solve problems outside it (although that may be technically possible).
DSL Usage Sample
DEMO
Benefits of DSL Approach High-level – tests are in the language of product management, at the user level Readable – product management can understand them Writable – easy for developer or QA to write new test Extensible – tests base is able to grow with DSL
Tips and Tricks Use test class hierarchy or test helpers Use builders, visitors and other design patterns Reuse domain model from application Some common methods move to base test class Minimize usage of browser instance in tests
Step 2: Introduce Page Object Create page map for your application
Page Object Pattern Index Page order search Search Page login search filter Main Page open see more Details Page close show me like this
Test Architecture with Page Object
Components Architecture Isolated logic Concepts separation Easier support Simplicity
Ways to Implement Page Object Duplicate Site Map with Packages and  Classes Move Site Structure  to UI-Element
DEMO
Tips and Tricks Allow chain invocations Basic page with browser details and common methods Expose only what is allowed to see or do on the page Don’t use browser instance in tests at all Use static analysis to check rules Use site map to prepare Page Objects
Step 3: Page Elements Divide pages on reusable elements
Page Consists of Elements Menu Checkbox Panel Link List of Items
Different Page Elements
Why Page Element Pattern?
Inversion of Control Hides the details of browser communication After Before Expose methods for what test can see and do
DEMO
Tellurium Project
Tellurium Basics: UI Module Groovy File Can Build Xpath in Runtime All Elements Element UID Isolated Locators Available Actions
Tellurium Basics: UI Object uid– unique in UI module  namespace – for future extension locator – locator of the UI object A base locator (relative XPath) A composite locator (object attributes) group – applied to some kinds of UI objects to switch on grouping locating respond – define JavaScript events the UI object could respond to some basic methods – isElementPresent, isVisible, isDisabled, waitForElementPresent, getText, mouseOver, mouseOut, getAttribute
Tellurium IDE and TrUMP
DEMO
Tips and Tricks Create elements when first need them Review and improve elements continuously Isolate and hide hacks inside elements Use open source libraries as basis Use annotations and other metadata techniques to simplify creation
Results ANALYSIS What we have at the end of long way?
Long Way Bring Us to… Reliable tests Reusable test code Separation of concepts  Expressive tested UI structure Short and clear tests Tests look more like acceptance tests Tests are understood by non-technical people
Company DSL Library Components may be reused between different applications and projects inside a company AJAX Components Company Portal Basic Components Online Store JSF Components Customer Service
Any Questions?

More Related Content

What's hot

DSL in test automation
DSL in test automationDSL in test automation
DSL in test automation
test test
 

What's hot (20)

Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework Designs
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium  Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Selenium Page Object Model Using Page Factory | Selenium Tutorial For Beginne...
Selenium Page Object Model Using Page Factory | Selenium Tutorial For Beginne...Selenium Page Object Model Using Page Factory | Selenium Tutorial For Beginne...
Selenium Page Object Model Using Page Factory | Selenium Tutorial For Beginne...
 
Test Automation
Test AutomationTest Automation
Test Automation
 
DSL in test automation
DSL in test automationDSL in test automation
DSL in test automation
 
Cucumber & gherkin language
Cucumber & gherkin languageCucumber & gherkin language
Cucumber & gherkin language
 
AEM and Sling
AEM and SlingAEM and Sling
AEM and Sling
 
Automation Framework Presentation
Automation Framework PresentationAutomation Framework Presentation
Automation Framework Presentation
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
 
BDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVABDD WITH CUCUMBER AND JAVA
BDD WITH CUCUMBER AND JAVA
 
Spring Web MVC
Spring Web MVCSpring Web MVC
Spring Web MVC
 
JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?
 
Automation testing introduction for FujiNet
Automation testing introduction for FujiNetAutomation testing introduction for FujiNet
Automation testing introduction for FujiNet
 
Selenium with Cucumber
Selenium  with Cucumber Selenium  with Cucumber
Selenium with Cucumber
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 

Viewers also liked

Бытовая классификация тестировщиков с точки зрения разработчика
Бытовая классификация тестировщиков с точки зрения разработчикаБытовая классификация тестировщиков с точки зрения разработчика
Бытовая классификация тестировщиков с точки зрения разработчика
Mikalai Alimenkou
 

Viewers also liked (20)

DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptxDSL, Page Object and WebDriver – the path to reliable functional tests.pptx
DSL, Page Object and WebDriver – the path to reliable functional tests.pptx
 
Better Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component PatternBetter Page Object Handling with Loadable Component Pattern
Better Page Object Handling with Loadable Component Pattern
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object pattern
 
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object Pattern
 
How QA engineers could affect quality?
How QA engineers could affect quality?How QA engineers could affect quality?
How QA engineers could affect quality?
 
Бытовая классификация тестировщиков с точки зрения разработчика
Бытовая классификация тестировщиков с точки зрения разработчикаБытовая классификация тестировщиков с точки зрения разработчика
Бытовая классификация тестировщиков с точки зрения разработчика
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
Compose all the things (Wicked Good Ember 2015)
Compose all the things (Wicked Good Ember 2015)Compose all the things (Wicked Good Ember 2015)
Compose all the things (Wicked Good Ember 2015)
 
Руководство по приготовлению бутербродов из Selenium
Руководство по приготовлению бутербродов из SeleniumРуководство по приготовлению бутербродов из Selenium
Руководство по приготовлению бутербродов из Selenium
 
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестамDSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
 
Advanced Selenium Workshop
Advanced Selenium WorkshopAdvanced Selenium Workshop
Advanced Selenium Workshop
 
10 things about BDD, Cucumber and SpecFlow - Long Version 2016
10 things about BDD, Cucumber and SpecFlow - Long Version 201610 things about BDD, Cucumber and SpecFlow - Long Version 2016
10 things about BDD, Cucumber and SpecFlow - Long Version 2016
 
Getting Started with Selenium
Getting Started with SeleniumGetting Started with Selenium
Getting Started with Selenium
 
A journey beyond the page object pattern
A journey beyond the page object patternA journey beyond the page object pattern
A journey beyond the page object pattern
 
Continuous Integration, the minimum viable product
Continuous Integration, the minimum viable productContinuous Integration, the minimum viable product
Continuous Integration, the minimum viable product
 
Automation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and BeyondAutomation Abstraction Layers: Page Objects and Beyond
Automation Abstraction Layers: Page Objects and Beyond
 
Serenity and the Journey Pattern
Serenity and the Journey PatternSerenity and the Journey Pattern
Serenity and the Journey Pattern
 
Web testing with Selenium
Web testing with SeleniumWeb testing with Selenium
Web testing with Selenium
 
Selenium
SeleniumSelenium
Selenium
 
Continuous Testing Meets the Classroom at Code.org
Continuous Testing Meets the Classroom at Code.orgContinuous Testing Meets the Classroom at Code.org
Continuous Testing Meets the Classroom at Code.org
 

Similar to DSL, Page Object and Selenium – a way to reliable functional tests

Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presented
Vijayan Reddy
 
Automated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS SitesAutomated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS Sites
joelabrahamsson
 
#2 integration + ui tests
#2 integration + ui tests#2 integration + ui tests
#2 integration + ui tests
eleksdev
 

Similar to DSL, Page Object and Selenium – a way to reliable functional tests (20)

Behavior Driven Development
Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven Development
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presented
 
Test Automation Framework Development Introduction
Test Automation Framework Development IntroductionTest Automation Framework Development Introduction
Test Automation Framework Development Introduction
 
Web Testen mit Selenium
Web Testen mit SeleniumWeb Testen mit Selenium
Web Testen mit Selenium
 
Manageable Robust Automated Ui Test
Manageable Robust Automated Ui TestManageable Robust Automated Ui Test
Manageable Robust Automated Ui Test
 
Automated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS SitesAutomated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS Sites
 
Software Testing Tools Training
Software Testing Tools TrainingSoftware Testing Tools Training
Software Testing Tools Training
 
Test team dynamics, Антон Мужайло
Test team dynamics, Антон МужайлоTest team dynamics, Антон Мужайло
Test team dynamics, Антон Мужайло
 
Asif resume
Asif resumeAsif resume
Asif resume
 
Slides for Automation Testing or End to End testing
Slides for Automation Testing or End to End testingSlides for Automation Testing or End to End testing
Slides for Automation Testing or End to End testing
 
Ashok_Resume
Ashok_ResumeAshok_Resume
Ashok_Resume
 
Selenium Webdriver Interview Questions
Selenium Webdriver Interview QuestionsSelenium Webdriver Interview Questions
Selenium Webdriver Interview Questions
 
Selenium tutorial to Beginners
Selenium tutorial to BeginnersSelenium tutorial to Beginners
Selenium tutorial to Beginners
 
Selenium WebDriver training
Selenium WebDriver trainingSelenium WebDriver training
Selenium WebDriver training
 
Naveenkumar.S
Naveenkumar.SNaveenkumar.S
Naveenkumar.S
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshers
 
#2 integration + ui tests
#2 integration + ui tests#2 integration + ui tests
#2 integration + ui tests
 
Selenium ui paradigm - DDD North 2
Selenium ui paradigm - DDD North 2Selenium ui paradigm - DDD North 2
Selenium ui paradigm - DDD North 2
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
 

More from Mikalai Alimenkou

Бытовая классификация тестировщиков с точки зрения разработчика
Бытовая классификация тестировщиков с точки зрения разработчикаБытовая классификация тестировщиков с точки зрения разработчика
Бытовая классификация тестировщиков с точки зрения разработчика
Mikalai Alimenkou
 

More from Mikalai Alimenkou (20)

Rise and fall of Story Points. Capacity based planning from the trenches.
Rise and fall of Story Points. Capacity based planning from the trenches.Rise and fall of Story Points. Capacity based planning from the trenches.
Rise and fall of Story Points. Capacity based planning from the trenches.
 
Static analysis tools as the best friend of QA
Static analysis tools as the best friend of QAStatic analysis tools as the best friend of QA
Static analysis tools as the best friend of QA
 
Modern CI/CD in the microservices world with Kubernetes
Modern CI/CD in the microservices world with KubernetesModern CI/CD in the microservices world with Kubernetes
Modern CI/CD in the microservices world with Kubernetes
 
Saga about distributed business transactions in microservices world
Saga about distributed business transactions in microservices worldSaga about distributed business transactions in microservices world
Saga about distributed business transactions in microservices world
 
Effectiveness tips from Kubernetes trenches by Captain Obvious
Effectiveness tips from Kubernetes trenches by Captain ObviousEffectiveness tips from Kubernetes trenches by Captain Obvious
Effectiveness tips from Kubernetes trenches by Captain Obvious
 
Ride the database in JUnit tests with Database Rider
Ride the database in JUnit tests with Database RiderRide the database in JUnit tests with Database Rider
Ride the database in JUnit tests with Database Rider
 
Wastful waste or why everything is so slow in development
Wastful waste or why everything is so slow in developmentWastful waste or why everything is so slow in development
Wastful waste or why everything is so slow in development
 
Hexagonal architecture with Spring Boot
Hexagonal architecture with Spring BootHexagonal architecture with Spring Boot
Hexagonal architecture with Spring Boot
 
Wastful waste or why everything is so slow in development
Wastful waste or why everything is so slow in developmentWastful waste or why everything is so slow in development
Wastful waste or why everything is so slow in development
 
DevOps checklist or how to understand where is your team in DevOps landscape ...
DevOps checklist or how to understand where is your team in DevOps landscape ...DevOps checklist or how to understand where is your team in DevOps landscape ...
DevOps checklist or how to understand where is your team in DevOps landscape ...
 
DevOps checklist or how to understand where is your team in DevOps landscape
DevOps checklist or how to understand where is your team in DevOps landscapeDevOps checklist or how to understand where is your team in DevOps landscape
DevOps checklist or how to understand where is your team in DevOps landscape
 
Практические трудности в разработке Медкарты для целой страны
Практические трудности в разработке Медкарты для целой страныПрактические трудности в разработке Медкарты для целой страны
Практические трудности в разработке Медкарты для целой страны
 
Hexagonal architecture with Spring Boot [EPAM Java online conference]
Hexagonal architecture with Spring Boot [EPAM Java online conference]Hexagonal architecture with Spring Boot [EPAM Java online conference]
Hexagonal architecture with Spring Boot [EPAM Java online conference]
 
Bro, manage test data like a pro! [QA Fest 2018]
Bro, manage test data like a pro! [QA Fest 2018]Bro, manage test data like a pro! [QA Fest 2018]
Bro, manage test data like a pro! [QA Fest 2018]
 
Agile antipatterns: review after 10 years of practice
Agile antipatterns: review after 10 years of practiceAgile antipatterns: review after 10 years of practice
Agile antipatterns: review after 10 years of practice
 
Hexagonal architecture with Spring Boot
Hexagonal architecture with Spring BootHexagonal architecture with Spring Boot
Hexagonal architecture with Spring Boot
 
Bro, manage test data like a pro!
Bro, manage test data like a pro!Bro, manage test data like a pro!
Bro, manage test data like a pro!
 
Бытовая классификация тестировщиков с точки зрения разработчика
Бытовая классификация тестировщиков с точки зрения разработчикаБытовая классификация тестировщиков с точки зрения разработчика
Бытовая классификация тестировщиков с точки зрения разработчика
 
Code Review tool for personal effectiveness and waste analysis
Code Review tool for personal effectiveness and waste analysisCode Review tool for personal effectiveness and waste analysis
Code Review tool for personal effectiveness and waste analysis
 
Funny stories and anti-patterns from DevOps landscape
Funny stories and anti-patterns from DevOps landscapeFunny stories and anti-patterns from DevOps landscape
Funny stories and anti-patterns from DevOps landscape
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

DSL, Page Object and Selenium – a way to reliable functional tests

  • 1. DSL, Page Object and Selenium – a way to reliable functional tests Mikalai Alimenkou http://xpinjection.com 26.02.2011
  • 2. Background Java Technical Lead/Scrum Master at Zoral Labs 6+ years in software development 4+ years of working by Agile methodologies Expert in Agile engineering practices Agile coach (TDD, Testing, Planning, etc.)at XP Injection (http://xpinjection.com)
  • 3. Agenda Selenium tests issues Step 1: DSL introduction Step 2: Page Object pattern Step 3: Page Element pattern Results analysis
  • 4. Selenium TESTS Issues When you have a hammer, everything looks like a nail
  • 5. Test Components Application Driver Test Data Test Logic
  • 6. How Selenium Works? Get Browser InvokeCommands Provide Data Use Locators
  • 7. Selenium Tests Issues: Verbose xpath=//input[@value=‘continue’] browser.enter… browser.click… css=#results dip p.first browser.getXpathCount… id=greenButton browser.waitForPageToLoad… browser.check…
  • 8. Selenium Tests Issues: Not Expressive
  • 10. Selenium Tests Issues: Fragile browser.click("//input[@id=(//label[text()='Fax']/@for)] "); What is going on here? browser.getText(“//div[@id='App']/div/p[4]/div[1]/h4[@class='Online']”); Depends too much on page structure!
  • 12. What is the Primary Goal? To enable reliable stable tests we need to separate all parts as much as possible
  • 13. Ideal Testing Framework Test Data Storage Technical Data Storage
  • 14. Step 1: Introduce DSL Create domain-specific language for your application
  • 15. Definition of DSL A domain-specific language (DSL) is a programming language or specification language dedicated to a particular problem domain, that is created specifically to solveproblems in this particular domain and is not intended to be able to solve problems outside it (although that may be technically possible).
  • 17. DEMO
  • 18. Benefits of DSL Approach High-level – tests are in the language of product management, at the user level Readable – product management can understand them Writable – easy for developer or QA to write new test Extensible – tests base is able to grow with DSL
  • 19. Tips and Tricks Use test class hierarchy or test helpers Use builders, visitors and other design patterns Reuse domain model from application Some common methods move to base test class Minimize usage of browser instance in tests
  • 20. Step 2: Introduce Page Object Create page map for your application
  • 21. Page Object Pattern Index Page order search Search Page login search filter Main Page open see more Details Page close show me like this
  • 22. Test Architecture with Page Object
  • 23. Components Architecture Isolated logic Concepts separation Easier support Simplicity
  • 24. Ways to Implement Page Object Duplicate Site Map with Packages and Classes Move Site Structure to UI-Element
  • 25. DEMO
  • 26. Tips and Tricks Allow chain invocations Basic page with browser details and common methods Expose only what is allowed to see or do on the page Don’t use browser instance in tests at all Use static analysis to check rules Use site map to prepare Page Objects
  • 27. Step 3: Page Elements Divide pages on reusable elements
  • 28. Page Consists of Elements Menu Checkbox Panel Link List of Items
  • 30. Why Page Element Pattern?
  • 31. Inversion of Control Hides the details of browser communication After Before Expose methods for what test can see and do
  • 32. DEMO
  • 34. Tellurium Basics: UI Module Groovy File Can Build Xpath in Runtime All Elements Element UID Isolated Locators Available Actions
  • 35. Tellurium Basics: UI Object uid– unique in UI module namespace – for future extension locator – locator of the UI object A base locator (relative XPath) A composite locator (object attributes) group – applied to some kinds of UI objects to switch on grouping locating respond – define JavaScript events the UI object could respond to some basic methods – isElementPresent, isVisible, isDisabled, waitForElementPresent, getText, mouseOver, mouseOut, getAttribute
  • 37. DEMO
  • 38. Tips and Tricks Create elements when first need them Review and improve elements continuously Isolate and hide hacks inside elements Use open source libraries as basis Use annotations and other metadata techniques to simplify creation
  • 39. Results ANALYSIS What we have at the end of long way?
  • 40. Long Way Bring Us to… Reliable tests Reusable test code Separation of concepts Expressive tested UI structure Short and clear tests Tests look more like acceptance tests Tests are understood by non-technical people
  • 41. Company DSL Library Components may be reused between different applications and projects inside a company AJAX Components Company Portal Basic Components Online Store JSF Components Customer Service