SlideShare uma empresa Scribd logo
1 de 143
Automated
 UI Testing
Done Right
Mehdi Khalili
Senior Developer at Readify

Active Open Source Projects:
  • BDDfy
  • Seleno
  • Humanizer

Blog: www.mehdi-khalili.com
Twitter: @MehdiKhalili
These practices are performed by
professional developers and testers.

Please DO try this at home

Authorized and written by Mehdi Khalili
framework agnostic ideas and patterns
can apply these with any
UI and UI Testing framework
… but for this talk we are going to use
Selenium
an awesome automated UI testing
         framework
Selenium
   http://seleniumhq.org/projects/webdriver/




PM> Install-Package Selenium.WebDriver
BDDfy
A simple BDD framework to use and extend!
   BDDfy turns your traditional unit tests
           into BDD behaviours
BDDfy
 http://teststack.github.com/TestStack.BDDfy/




PM> Install-Package TestStack.BDDfy
Seleno
  helps you write
Automated UI Tests
  the RIGHT way!
Seleno
  http://teststack.github.com/TestStack.Seleno/




PM> Install-Package TestStack.Seleno
samples are from Seleno
codebase and can be found at
 https://github.com/TestStack/TestStack.Seleno
In a nutshell


•   UI Testing: a likely failure
•   From horrid to awesome in three steps
•   A few tips (time permitting)
•   Q&A
UI Testing!
a likely failure
speaking of
experience
a lot of teams
      do
  UI Testing
a lot of teams
have a “great start” at
      UI Testing
a lot of teams
then struggle with
    UI Testing
a lot of teams
  then fail at
   UI Testing
because   UI Tests are
because   UI Tests are
hard to maintain
because   UI Tests are
     brittle
but

  you can
mitigate
these issues
If you

 do it
RIGHT
test code
    is
  code
apply
S.R.P.
on your
code?
apply
S.R.P.
on your
tests
apply
D.R.Y.
on your
tests
care about your
tests as much as
you care about your
      code
or you will
waste a lot of time
or you will
   fail
from horrid to awesome
      in four three steps
a quick look
          at the sample

https://github.com/TestStack/TestStack.Seleno
guaranteed to
  fail
procedural
duplicated logic
duplicated selectors
magic strings
Step 1:




your tests with
 Page Object
Page Object
     brings


 OO to tests
a Page Object
 per page under test
a   link on the page
      becomes a
method on the
     Page Object
clicking a link on the page
turns into calling a method
     on the Page Object
instead of


you will get
textbox
     a
on the page becomes a
string property
 on the Page Object
filling a textbox on the
page turns into setting a
 string property on the
        Page Object
instead of


you will get
acheckbox
on the page becomes a
bool property
 on the Page Object
ticking a checkbox on the
 page turns into setting a
   bool property on the
       Page Object
anyaction
on the page becomes a
 method on the
     Page Object
… and you will get another
Page Object as the return
   value of the method
chain your calls
procedural
duplicating logic
duplicating selectors
magic strings
step 2:


    Page
 Components
Compose your Page Objects of
      smaller pieces
some pages are
some pages are

complex
remember

S.R.P.?
would you write



big    and   complex
 classes in your
    code?
care about your
        tests
    as much as
you care about your
        code
do NOT write


big   and complex
 Page Objects
use
Page Components
 to break
        down your
   Page Objects
use
Page Components
        for
panels      menus
       rows in grids
modal pop-ups
Page Components
      D.R.Y.
  your tests even more
instead of


you will get
and you can
compose other
  Page Objects
   using these
Page Components
Page Object &
Page Component
    lead into
    S.R.P.
Page Object &
Page Component
     D.R.Y.
    your test
... but
what about magic strings?
procedural
duplicating logic
duplicating selectors
magic strings
it is not
 only about
magic strings
the code is still
     ugly
step 3:




Strongly typed
 Page Object
you use
view models
 in your code
why not use
view models
in your tests?
(unofficial) step 4:


 Tests as Living
Documentation
write your UI Tests
        based on
acceptance criteria
use a BDD framework
  to implement your
acceptance criteria
use a BDD framework
 to turn your tests into
living documentation
use the
  test results
      as a
progress report
use the
  test results
as a support for
manual testing
A
few
tips
Do NOT use
Thread.Sleep
Thread.Sleep
  is slow
Thread.Sleep
 is brittle
often need to wait a bit
longer for things to load?
use implicit waits
need to wait longer
for specific elements to load?
use explicit waits
need to wait for an
AJAX call to finish?
use javascript
choose
right selectors
page structure
   changes
do
      NOT
     be fuzzy
with your selectors
do
         NOT
rely on the structure
    of your page
do
        NOT
    rely on the
surrounding elements
By.XPath("//ul[@id='album-list']/li[3]/a/span")



             you’re kidding, right?!
we use interfaces and
DI all over our code to
 make it unit testable
do what it takes to
support your tests
be explicit:
  add id on your
   elements to
support your tests
TARGET
your elements
   directly
     when possible
only one
   test
per action
do you have
workflows?
do one test per
 page/action
then do one test
 for entire flow
do NOT setup
 your required
state through UI
that will be
slow and brittle
setup your data
 through code
and navigate to
the page under
  test directly
use strongly typed
 actions for that
design by
interface!
  when you need it
do you support
multiple devices?
do you do
A/B testing?
create interface for
your Page Objects and
 use the interface in
   your test scripts
ISomePage



         A/B testing
PCPage                 iPadPage
           pages
… and use one
test script for all
 page variations
apply

YAGNI
  in your
test code
do

     NOT
      create a
    Page Object
until you need it
do

      NOT
   add an action to
     Page Object
until you need it
do

       NOT
   add a property to
     Page Object
until you need it
do

      NOT
   add a getter to
   your property
until you need it
run and maintain
     your tests
run
  your tests
frequently
fix
  the broken test right

when it breaks
tests you
 do not run
     ===
broken tests
broken tests you
   do not fix
      ===
 ignored tests
… and finally
Confucius says …
UI Testing
 is hard
and could be a
waste of time
so
do NOT do it
     or
do it RIGHT
when   Done Right it is
 well worth it
thanks for
 attending
time for a few Qs
                                  &
                   hopefully few As

Blog:            www.mehdi-khalili.com
Twitter:         @MehdiKhalili


http://www.mehdi-khalili.com/presentations/automated-ui-testing-done-right-at-dddsydney
With thanks to our sponsors
Please complete your feedback
  forms, and return them to the
registration desk for a chance
                       to win a
                  Nokia Lumia

Mais conteúdo relacionado

Mais procurados

selenium training | selenium course | selenium video tutorial | selenium for ...
selenium training | selenium course | selenium video tutorial | selenium for ...selenium training | selenium course | selenium video tutorial | selenium for ...
selenium training | selenium course | selenium video tutorial | selenium for ...
Nancy Thomas
 

Mais procurados (20)

Selenium web driver
Selenium web driverSelenium web driver
Selenium web driver
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
Test Automation and Selenium
Test Automation and SeleniumTest Automation and Selenium
Test Automation and Selenium
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
Protractor Testing Automation Tool Framework / Jasmine Reporters
Protractor Testing Automation Tool Framework / Jasmine ReportersProtractor Testing Automation Tool Framework / Jasmine Reporters
Protractor Testing Automation Tool Framework / Jasmine Reporters
 
Selenium IDE LOCATORS
Selenium IDE LOCATORSSelenium IDE LOCATORS
Selenium IDE LOCATORS
 
Mobile Testing with Selenium 2 by Jason Huggins
Mobile Testing with Selenium 2 by Jason HugginsMobile Testing with Selenium 2 by Jason Huggins
Mobile Testing with Selenium 2 by Jason Huggins
 
selenium training | selenium course | selenium video tutorial | selenium for ...
selenium training | selenium course | selenium video tutorial | selenium for ...selenium training | selenium course | selenium video tutorial | selenium for ...
selenium training | selenium course | selenium video tutorial | selenium for ...
 
Web automation using selenium.ppt
Web automation using selenium.pptWeb automation using selenium.ppt
Web automation using selenium.ppt
 
UI Testing Best Practices - An Expected Journey
UI Testing Best Practices - An Expected JourneyUI Testing Best Practices - An Expected Journey
UI Testing Best Practices - An Expected Journey
 
Selenium presentation
Selenium presentationSelenium presentation
Selenium presentation
 
Introduction to Selenium
Introduction to SeleniumIntroduction to Selenium
Introduction to Selenium
 
Selenium
SeleniumSelenium
Selenium
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - Introduction
 
Selenium ide material (1)
Selenium ide material (1)Selenium ide material (1)
Selenium ide material (1)
 
Integrating Selenium testing infrastructure into Scala Project
Integrating Selenium testing infrastructure into Scala ProjectIntegrating Selenium testing infrastructure into Scala Project
Integrating Selenium testing infrastructure into Scala Project
 
Selenium WebDriver FAQ's
Selenium WebDriver FAQ'sSelenium WebDriver FAQ's
Selenium WebDriver FAQ's
 
Selenium Automation
Selenium AutomationSelenium Automation
Selenium Automation
 
UI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLCUI Testing Automation - Alex Kalinovsky - CreamTec LLC
UI Testing Automation - Alex Kalinovsky - CreamTec LLC
 

Destaque

Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using Cucumber
KMS Technology
 

Destaque (18)

Microservices lessons from trenches
Microservices lessons from trenchesMicroservices lessons from trenches
Microservices lessons from trenches
 
Und es geht doch - TDD für GUIs
Und es geht doch - TDD für GUIsUnd es geht doch - TDD für GUIs
Und es geht doch - TDD für GUIs
 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
 
Git vs svn
Git vs svnGit vs svn
Git vs svn
 
Advanced Coded UI Testing
Advanced Coded UI TestingAdvanced Coded UI Testing
Advanced Coded UI Testing
 
Automated UI Testing
Automated UI TestingAutomated UI Testing
Automated UI Testing
 
TRENDWATCHING 2017
TRENDWATCHING 2017TRENDWATCHING 2017
TRENDWATCHING 2017
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using Cucumber
 
13 Personality Traits Of A Horrible Employee
13 Personality Traits Of A Horrible Employee13 Personality Traits Of A Horrible Employee
13 Personality Traits Of A Horrible Employee
 
Algorithms are the new gatekeepers
Algorithms are the new gatekeepersAlgorithms are the new gatekeepers
Algorithms are the new gatekeepers
 
Git from SVN
Git from SVNGit from SVN
Git from SVN
 
DWX 2014 - Coded UI in der Praxis: Von Lokalisierung bis Nachhaltigkeit
DWX 2014 -  Coded UI in der Praxis: Von Lokalisierung bis NachhaltigkeitDWX 2014 -  Coded UI in der Praxis: Von Lokalisierung bis Nachhaltigkeit
DWX 2014 - Coded UI in der Praxis: Von Lokalisierung bis Nachhaltigkeit
 
Automated testing of JavaFX UI components
Automated testing of JavaFX UI componentsAutomated testing of JavaFX UI components
Automated testing of JavaFX UI components
 
Versionierung mit Git und SourceTree
Versionierung mit Git und SourceTreeVersionierung mit Git und SourceTree
Versionierung mit Git und SourceTree
 
Présentation dld 2011
Présentation dld 2011Présentation dld 2011
Présentation dld 2011
 
A GUI Best-Practices Example: Ableton Live
A GUI Best-Practices Example: Ableton LiveA GUI Best-Practices Example: Ableton Live
A GUI Best-Practices Example: Ableton Live
 
Komfortable, systematische Modellierung und Automatisierung von GUI-Tests
Komfortable, systematische Modellierung und Automatisierung von GUI-TestsKomfortable, systematische Modellierung und Automatisierung von GUI-Tests
Komfortable, systematische Modellierung und Automatisierung von GUI-Tests
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework Designs
 

Semelhante a Automated UI testing done right (DDDSydney)

Acceptance Testing of Web UI
Acceptance Testing of Web UIAcceptance Testing of Web UI
Acceptance Testing of Web UI
Vladimir Tsukur
 
Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)
Sauce Labs
 
AtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
AtlasCamp 2011 - Five Strategies to Accelerate Plugin DevelopmentAtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
AtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
mrdon
 
Behaviour driven infrastructure
Behaviour driven infrastructureBehaviour driven infrastructure
Behaviour driven infrastructure
Lindsay Holmwood
 

Semelhante a Automated UI testing done right (DDDSydney) (20)

Acceptance Testing of Web UI
Acceptance Testing of Web UIAcceptance Testing of Web UI
Acceptance Testing of Web UI
 
Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully Mastering Test Automation: How to Use Selenium Successfully
Mastering Test Automation: How to Use Selenium Successfully
 
Graceful Failure with Selenium and Continuous Integration
Graceful Failure with Selenium and Continuous IntegrationGraceful Failure with Selenium and Continuous Integration
Graceful Failure with Selenium and Continuous Integration
 
How to Deliver the Right Software (Specification by example)
How to Deliver the Right Software (Specification by example)How to Deliver the Right Software (Specification by example)
How to Deliver the Right Software (Specification by example)
 
Treating test code as production code
Treating test code as production codeTreating test code as production code
Treating test code as production code
 
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
 
How to use selenium successfully
How to use selenium successfullyHow to use selenium successfully
How to use selenium successfully
 
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестамDSL, Page Object и WebDriver – путь к надежным функциональным тестам
DSL, Page Object и WebDriver – путь к надежным функциональным тестам
 
Browser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.jsBrowser Automated Testing Frameworks - Nightwatch.js
Browser Automated Testing Frameworks - Nightwatch.js
 
Web driver selenium simplified
Web driver selenium simplifiedWeb driver selenium simplified
Web driver selenium simplified
 
How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)
 
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
 
DSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional testsDSL, Page Object and Selenium – a way to reliable functional tests
DSL, Page Object and Selenium – a way to reliable functional tests
 
Usable Software Design
Usable Software DesignUsable Software Design
Usable Software Design
 
AtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
AtlasCamp 2011 - Five Strategies to Accelerate Plugin DevelopmentAtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
AtlasCamp 2011 - Five Strategies to Accelerate Plugin Development
 
How To Use Selenium Successfully
How To Use Selenium SuccessfullyHow To Use Selenium Successfully
How To Use Selenium Successfully
 
Behaviour driven infrastructure
Behaviour driven infrastructureBehaviour driven infrastructure
Behaviour driven infrastructure
 
Survive the Chaos - S4H151 - SAP TechED Barcelona 2017 - Lecture
Survive the Chaos - S4H151 - SAP TechED Barcelona 2017 - LectureSurvive the Chaos - S4H151 - SAP TechED Barcelona 2017 - Lecture
Survive the Chaos - S4H151 - SAP TechED Barcelona 2017 - Lecture
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Automated UI testing done right (DDDSydney)

Notas do Editor

  1. The framework is called BDDfy because it BDDfies (as in turns into BDD) your otherwise traditional unit tests
  2. The framework is called BDDfy because it BDDfies (as in turns into BDD) your otherwise traditional unit tests
  3. Some code here + demoWhy it is different from the previous approachBut changing a name still breaks the tests
  4. Show a demo of a change on an id that breaks a test
  5. Show a demo of a change on an id that breaks a test
  6. Showing the demo with Page<T>Showing the differenceShowing that changing a property name gives compile time error
  7. UI Tests are no different
  8. Add a photo of an element being targetted