SlideShare uma empresa Scribd logo
1 de 53
Baixar para ler offline
BDD, ATDD, Page Objects
          The Road to Sustainable Web Testing




John Ferguson Smart
So who is this guy, anyway?
               Consulta
                       nt
               Trainer
              Mentor
              Author
             Speaker
             Coder
   John Fer
            guson S
                    mar t
Java Power Tools Bootcamp at Skills Matter
           ALL YOUR AGILE JAVA TOOLS
           TRAINING ARE BELONG TO US
                          bDr iver
                m	
  2/We
mave     Seleniu        Hudson
    n
                                  BDD
             JUnit
TD
     D

                                London
                           January 24-28 2011
Don’t let your web tests end up like this!
The Three Ways of Automated Web Testing




        Record/Replay

      Scripting

Page Objects
Record-replay automated tests




      Promise           Reality
Record-replay automated tests
Script-based automated tests

Selenium RC

      HTMLUnit

              JWebUnit

                     Canoe Webtest

                               Watir
Script-based automated tests

Selenium RC

      HTMLUnit

              JWebUnit

                     Canoe Webtest

                               Watir
What we’d like to have...
                     D.R.Y
      Don’t Repeat Yourself
What we’d like to have...




   Reusable building blocks
What we’d like to have...




A communication tool
Introducing Page Objects

Reusable


 Low
 maintenance


  Speak your language
Page Objects




          are reusable components
Page Objects




          hide unnecessary details
Page Objects




               are low maintenance
Page Objects




        speak everybody’s language
Page Objects in action




            An example
Page Objects in action
The old way - Selenium RC
 selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com/");

 selenium.open("http://www.google.com");
 selenium.waitForPageToLoad(5000);

 selenium.type("q", "cats");
 selenium.click("BtnG");
 selenium.waitForPageToLoad(5000);

 assertThat(selenium.isTextPresent("cats"), is(true));
Page Objects in action
The new way - Using Page Objects
 WebDriver driver = new FirefoxDriver();
 GoogleSearchPage page = new GoogleSearchPage(driver);

 page.open();
 page.searchFor("cats");

 assertThat(page.getTitle(), containsString("cats") );

 page.close();
Page Objects in action
The new way - Using Page Objects
 WebDriver driver = new FirefoxDriver();
 GoogleSearchPage page = new GoogleSearchPage(driver);

 page.open();
 page.searchFor("cats");

 assertThat(page.getTitle(), containsString("cats") );

 page.close();
                                                         GoogleSearchPage

                                                     open()
                                                     close()
                                                     searchFor( query : String )
                                                     clickOnFeelingLucky()
                                                     openAdvancedSearchOptions()
                                                     ...
Page Objects in action
The new way - another example




                    WebDriver driver = new FirefoxDriver();
                    GoogleSearchPage page = new GoogleSearchPage(driver);
    Hides HTML
                    page.open()
          details   page.typeIntoSearchBox("cats");
                    List<String> suggestions = page.getSuggestions();
        Uses
                    assertThat(suggestions, hasItem("cats and dogs"));
     business
       terms        page.close();
From Pages Objects to BDD




Taking expressive tests
to the next level
BDD in action
WebDriver driver = new FirefoxDriver();
GoogleSearchPage page = new GoogleSearchPage(driver);

page.open()
page.typeIntoSearchBox("cats");
List<String> suggestions = page.getSuggestions();

assertThat(suggestions, hasItem("cats and dogs"));

page.close();




But would your testers
      understand this?
BDD in action                                                         Much more
                                                                        readable

using "google-search"

scenario "Searching for 'cats' on Google", {
	

 when "the user types 'cats' in the search box", {
	

 	

 onTheWebPage.typeIntoSearchBox "cats"
	

 }
	

 then "the drop-down suggestions should include 'cats and dogs'"
	

 	

 theWebPage.suggestions.shouldHave "cats and dogs"
	

 }
}




                        Still uses Page Objects
                                under the hood
                                                         How about this?
BDD in action




                More readable
                    reporting
So how does it work?
                   Easyb Plugin
using "google-search"

scenario "Searching for 'cats' on Google",{
	

 when "the user types 'cats' in the search box", {
	

 	

 onTheWebPage.typeIntoSearchBox "cats"
	

 }
	

 then "the drop-down suggestions should include 'cats and dogs'"
	

 	

 theWebPage.suggestions.shouldHave "cats and dogs"
	

 }
}
                                                                          Page Objects




                                                                      Page Navigation
Automated Acceptance Tests




      Where are your goal posts?
Automated Acceptance Tests




   Unit tests are for   Acceptance tests are
      developers          for everyone else
Automated Acceptance Tests




   Unit tests are for   Acceptance tests are
      developers          for everyone else
Automated Acceptance Tests
                                  Passing
                                acceptance
                                   tests




                              Pending
                             acceptance
                                tests
Automated Acceptance Tests

                     Acceptance
                        tests




                              Pending
                             acceptance
                                tests
Automated Acceptance Tests
tags ["acceptance", "sprint-1"]                            Implement these in
scenario "An empty grid should produce an empty grid",{
                                                                Sprint 1
	 when "the user chooses to start a new game", {
	 	 newGamePage = homePage.clickOnNewGameLink()
	 }
	 then "the user is invited to enter the initial state of the universe", {
	 	 newGamePage.text.shouldHave "Please seed your universe"	 	 	 	
	 }
}

scenario "The user can seed the universe with an initial grid",{
	 given "the user is on the new grid page", {
	 	 newGridPage = homePage.clickOnNewGameLink()
	 }
	 when "that the user clicks on Go without picking any cells", {
        gridDisplayPage = newGridPage.clickOnGoButton()
	 }
	 then "the application will display an empty universe", {
	 	 String[][] anEmptyGrid = [[".", ".", "."],
	 	                              [".", ".", "."],
	 	 	 	 	                        [".", ".", "."]]
	 	 gridDisplayPage.displayedGrid.shouldBe anEmptyGrid
	 }
}
And now for
the case studies
Case Study




   Government online form processing
Architecture - fitting it all together


      Acceptance tests

              Easyb Plugin


            Page Objects



                  Integration
                     tests      JUnit

        Web Application
The application
                  Perl and Java



                    Lots of forms



                       Ugly colours
What the tester uses
using "ecert"                                      Custom easyb plugin
tags "TC02"
                                                              Plugin handles
before "we are connected to the UAT environment", {
                                                              authentication
	 given "we are connected to the UAT environment", {
	 	 connecting.to('uat').withUser('a_tester')
	 }
}                                                            Business-level tests
scenario "The user opens the 'New Export Certificate' page and selects a country",{
	 when "the user clicks on the 'New Export Certificate' menu", {
	 	 onTheWebPage.navigationPanel.clickOnNewExportCertificate()	 	
	 }
	 and "the user chooses USA and clicks on 'Show Data Entry'", {
	 	 onTheWebPage.selectDeclarationFormFor 'United States'	  	
	 }
	 then "we should be on the US Export Certification Preparation page", {
	 	 theWebPage.asText.shouldHave "Export Certificate Preparation"	 	
	 	 theWebPage.asText.shouldHave "Declarations for United States"	 	
	 }
	 and "the 'Raise New Blank Export Certificate' is default and selected", {
	 	 theWebPage.raiseNewBlankCertificate.shouldBeSelected()
	 }
}
More nice screens
What the tester uses
...
scenario "The user fills in the Export Certificate Submission Form",{
	 when "we fill in the export certificate details", {
	 	 theWebPage.with {
	 	       certificateNumber = '123456'
	 	 	 consignor = 'LANEXCO1'
	 	 	 importerID = '123'                                 Groovy shortcuts
	 	 	 importerName = 'ImportsRUs'
	 	 	 importerRepresentative = 'local guy'
	 	 	 officialInformation = 'very important'
	 	 	 transportMode = 'AIR'
	 	 	 carrierName = 'AirNZ'                               Business-level tests
	 	 	 productItem(1).description = 'Product data'
	 	 	 productItem(1).harmonizedSystemCode = '020110'
	 	 	 productItem(1).with {
	 	 	 	 process(1).with {
	 	 	 	 	 type = 'Freezing'
	 	 	 	 	 processingStartDate = '01/01/2010'                      Handling
	 	 	 	 	 processingEndDate = '02/01/2010'                      nested forms
	 	 	 	 	 appliedBy = 'some dude'	      	 	
	 	 	 	 	 overrideSelected()
	 	 	 	 }
           ...
What the Page Objects look like
public class ECertNavigationPanel extends AuthenticatedWebPage {

	       @FindBy(linkText="XML Submit")
	       WebElement xmlSubmit;
	                                                           WebDriver annotations
	       @FindBy(linkText="New Export Certificate")
	       WebElement newExportCertificate;

	       public ECertNavigationPanel(WebDriver driver) {
	       	   super(driver);
	       }
	       	   	
	       public WebElement getXmlSubmit() {...}

	       public WebElement getNewExportCertificate() {...}

    	   public ECertSubmitXmlPage clickOnXmlSubmit() {...}
	
	       public ExportCertificatePreparationPage clickOnNewExportCertificate() {...}	
	
	
}
Case Study




      Class Report
   An online reporting
      tool for lawyers
          h"p://customfirst.com
Architecture - fitting it all together


          Regression/
       Integration tests




             Page Objects




         Web Application
The application
                  RUI Application




                     Lots of AJAX
                              !
What the tests look like
@Mixin (SeleniumTest)
class ReportViewerTests extends AbstractSeleniumBaseTest
{
    ViewerPage viewerPage
                                                              Setting up the
	
	
    public void setUp() {
        super.setUp()
                                                               Page Object
	   	   TestFixtures.loadData()
         viewerPage = new ViewerPage(selenium, contextPath)
	   	   viewerPage.openHomePage()
    }

	   public void testClickingGLReportsIconShouldDisplaySubFolders() {
	       viewerPage.clickFolderOpenIcon("GL Reports")
	       assertTrue viewerPage.folderPresent("Accounts")                Testing the app
	       assertTrue viewerPage.folderPresent("Test Reports")
    }

    public void testClickingOnASubFolderShouldDisplayReports() {
	   	   viewerPage.clickFolderOpenIcon("GL Reports")
	   	   assertTrue viewerPage.folderPresent("Test Reports")
	       viewerPage.clickFolder "Test Reports"
	   	   assertTrue viewerPage.reportRowPresent("Test Reports","Aged Debtors By Client")
	   	   assertTrue viewerPage.reportRowPresent("Test Reports","Chart")
    }
	   ...
What the Page Objects look like
class ViewerPage   extends AbstractPageObject{

  public ViewerPage(def selenium, def contextPath) {           Business-friendly
    super(selenium, contextPath)
  }                                                                methods
  public void clickFolder(String folderName) {...}

  public void clickFolderOpenIcon(String folderId) {...}	

  public boolean   folderPresent(String folderName){...}

  public boolean reportRowPresent(String folder,String rowName){...}

  public boolean reportParameterPresent(String reportName,String parameterName){...}

  public boolean reportRowTextPresent(String folder,String reportName,String text){...}
  ...
Case Study




Financial software
The application
                  Looks a bit like
                    this one...
                    (but more complex)

                          (and top secret)

                               (Shhhhhh!)




                               Again, lots of AJAX
                                                !
Page Components
                                                              Reusable component
class RadioButton {
    WebElement button
    WebElement buttonContainer;
    def buttonId
    def driver

    void clickButton() {
        initButton()
        button.click();
    }

    void shouldBeEnabled() {
        assert !isDisabled();
    }

    void shouldBeDisabled() {
        assert isDisabled();
    }                                                       Horrible nasty GWT code
    private boolean isDisabled() {
        initButton()
        return buttonContainer.getAttribute("class").contains("x-item-disabled");
    }

    private void initButton()
    {
        if (button==null) {
            buttonContainer=driver.findElement(By.id("gwt-debug-${buttonId}_BUTTON"));
            button=driver.findElement(By.xpath("//input[contains(@value, ${buttonId}-input)]"));
        }
    }
}
Page Components
 @Test
 public void userShouldBecomeOwnerOfCurrentWorkItem() {
     page.workItemTree.selectEntryCalled("Stuff to do")
     ...
     page.assignButton.shouldBeEnabled()
     page.assignButton.click();                    Click on a button
     page.assignButton.shouldBeHidden();
     page.retryButton.shouldBeEnabled();
     page.saveButton.shouldBeDisabled()
     page.saveButton.shouldBePresent();               Custom asserts
 }

       scenario "No work items should initially appear on the screen",{
           when "the user opens the page", {
               page.open()
           }
           and "the Item Tree 'Show all' check box should not be ticked", {
               assert page.itemTree.showAll.isNotChecked()
           }
           and "the Item Tree should contain no work items", {
               assert page.itemTree.isEmpty()
           }
       }                                                  BDD-style tests
Page Components
class Grid {
                                            A Grid (table) component
    def driver
    def gridId

    def getAt(int i) {                               It looks like an array
        def gridRows = getGridRows()
        return gridRows[i]
    }

    def size() {
        def gridRows = getGridRows()
        return gridRows.size()
    }

    def shouldHaveARowWith(def map) {
        def gridRows = getGridRows()

        def matchingRowFound = true

        for(entry in map) {
            def gridRow = gridRows.find { row ->
                row[entry.key] == entry.value
            }

               matchingRowFound = gridRow != null
        }

        return matchingRowFound
    }
Page Components
 @Test
 void theSummaryItemChangesToReflectTreeChoice() {
     page.itemTree.selectEntryCalled("Stuff to do")       This is not an array
     assert page.itemSummaryGrid.size() == 1

     def highlightedItemSummaryRow = page.itemSummaryGrid[0]
     assert highlightedItemSummaryRow.customerName == "ACME Inc"
 }
ATDD, BDD and Page Objects
Clean, precise, well-designed




                 Powerful, robust, low-maintenance
                                               John	
  Ferguson	
  Smart
                                Email:	
  john.smart@wakaleo.com
                                 Web:	
  h"p://www.wakaleo.com
                                                   Twi"er:	
  wakaleo

Mais conteúdo relacionado

Mais procurados

Realm or: How I learned to stop worrying and love my app database
Realm or: How I learned to stop worrying and love my app databaseRealm or: How I learned to stop worrying and love my app database
Realm or: How I learned to stop worrying and love my app databaseSergi Martínez
 
JSON and Swift, Still A Better Love Story Than Twilight
JSON and Swift, Still A Better Love Story Than TwilightJSON and Swift, Still A Better Love Story Than Twilight
JSON and Swift, Still A Better Love Story Than TwilightDonny Wals
 
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateEffiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateThorben Janssen
 
Windows 8 JavaScript (Wonderland)
Windows 8 JavaScript (Wonderland)Windows 8 JavaScript (Wonderland)
Windows 8 JavaScript (Wonderland)Christopher Bennage
 
InheritedWidget is your friend - GDG London (2018-08-08)
InheritedWidget is your friend - GDG London (2018-08-08)InheritedWidget is your friend - GDG London (2018-08-08)
InheritedWidget is your friend - GDG London (2018-08-08)Andrea Bizzotto
 
Testable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptTestable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptJon Kruger
 
JavaEE 8 on a diet with Payara Micro 5
JavaEE 8 on a diet with Payara Micro 5JavaEE 8 on a diet with Payara Micro 5
JavaEE 8 on a diet with Payara Micro 5Payara
 
Final microsoft cloud summit - windows azure building block services
Final   microsoft cloud summit - windows azure building block servicesFinal   microsoft cloud summit - windows azure building block services
Final microsoft cloud summit - windows azure building block servicesstratospheres
 
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperVenturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperJon Kruger
 
13 networking, mobile services, and authentication
13   networking, mobile services, and authentication13   networking, mobile services, and authentication
13 networking, mobile services, and authenticationWindowsPhoneRocks
 
Di web tech mail (no subject)
Di web tech mail   (no subject)Di web tech mail   (no subject)
Di web tech mail (no subject)shubhamvcs
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Watersmichael.labriola
 

Mais procurados (19)

Realm or: How I learned to stop worrying and love my app database
Realm or: How I learned to stop worrying and love my app databaseRealm or: How I learned to stop worrying and love my app database
Realm or: How I learned to stop worrying and love my app database
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
JSON and Swift, Still A Better Love Story Than Twilight
JSON and Swift, Still A Better Love Story Than TwilightJSON and Swift, Still A Better Love Story Than Twilight
JSON and Swift, Still A Better Love Story Than Twilight
 
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und HibernateEffiziente Datenpersistierung mit JPA 2.1 und Hibernate
Effiziente Datenpersistierung mit JPA 2.1 und Hibernate
 
Why realm?
Why realm?Why realm?
Why realm?
 
Kode vb.net
Kode vb.netKode vb.net
Kode vb.net
 
Windows 8 JavaScript (Wonderland)
Windows 8 JavaScript (Wonderland)Windows 8 JavaScript (Wonderland)
Windows 8 JavaScript (Wonderland)
 
InheritedWidget is your friend - GDG London (2018-08-08)
InheritedWidget is your friend - GDG London (2018-08-08)InheritedWidget is your friend - GDG London (2018-08-08)
InheritedWidget is your friend - GDG London (2018-08-08)
 
Testable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScriptTestable, Object-Oriented JavaScript
Testable, Object-Oriented JavaScript
 
Vaadin7
Vaadin7Vaadin7
Vaadin7
 
Di and Dagger
Di and DaggerDi and Dagger
Di and Dagger
 
JavaEE 8 on a diet with Payara Micro 5
JavaEE 8 on a diet with Payara Micro 5JavaEE 8 on a diet with Payara Micro 5
JavaEE 8 on a diet with Payara Micro 5
 
Air Drag And Drop
Air Drag And DropAir Drag And Drop
Air Drag And Drop
 
Final microsoft cloud summit - windows azure building block services
Final   microsoft cloud summit - windows azure building block servicesFinal   microsoft cloud summit - windows azure building block services
Final microsoft cloud summit - windows azure building block services
 
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby DeveloperVenturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
Venturing Into The Wild: A .NET Developer's Experience As A Ruby Developer
 
13 networking, mobile services, and authentication
13   networking, mobile services, and authentication13   networking, mobile services, and authentication
13 networking, mobile services, and authentication
 
Di web tech mail (no subject)
Di web tech mail   (no subject)Di web tech mail   (no subject)
Di web tech mail (no subject)
 
Diving in the Flex Data Binding Waters
Diving in the Flex Data Binding WatersDiving in the Flex Data Binding Waters
Diving in the Flex Data Binding Waters
 
J Query Presentation of David
J Query Presentation of DavidJ Query Presentation of David
J Query Presentation of David
 

Semelhante a BDD, ATDD, Page Objects: The Road to Sustainable Web Testing

JavaScript Misunderstood
JavaScript MisunderstoodJavaScript Misunderstood
JavaScript MisunderstoodBhavya Siddappa
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instrumentsArtem Nagornyi
 
Test strategy for web development
Test strategy for web developmentTest strategy for web development
Test strategy for web developmentalice yang
 
Experienced Selenium Interview questions
Experienced Selenium Interview questionsExperienced Selenium Interview questions
Experienced Selenium Interview questionsarchana singh
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e bigAndy Peterson
 
Workshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsWorkshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsSami Ekblad
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript EverywherePascal Rettig
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testingdrewz lin
 
Easy tests with Selenide and Easyb
Easy tests with Selenide and EasybEasy tests with Selenide and Easyb
Easy tests with Selenide and EasybIakiv Kramarenko
 
Integration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDBIntegration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDBMichal Bigos
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETBen Hall
 
Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchMats Bryntse
 
Kakunin E2E framework showcase
Kakunin E2E framework showcaseKakunin E2E framework showcase
Kakunin E2E framework showcaseThe Software House
 
Google Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and BeyondGoogle Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and Beyonddion
 
Google Play Services Rock
Google Play Services RockGoogle Play Services Rock
Google Play Services RockPeter Friese
 
An Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using ProtractorAn Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using ProtractorCubet Techno Labs
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideMek Srunyu Stittri
 
Taming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and GebTaming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and GebC4Media
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance testBryan Liu
 

Semelhante a BDD, ATDD, Page Objects: The Road to Sustainable Web Testing (20)

JavaScript Misunderstood
JavaScript MisunderstoodJavaScript Misunderstood
JavaScript Misunderstood
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
 
Test strategy for web development
Test strategy for web developmentTest strategy for web development
Test strategy for web development
 
Experienced Selenium Interview questions
Experienced Selenium Interview questionsExperienced Selenium Interview questions
Experienced Selenium Interview questions
 
Javascript unit testing, yes we can e big
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
 
Workshop: Building Vaadin add-ons
Workshop: Building Vaadin add-onsWorkshop: Building Vaadin add-ons
Workshop: Building Vaadin add-ons
 
Javascript Everywhere
Javascript EverywhereJavascript Everywhere
Javascript Everywhere
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
Easy tests with Selenide and Easyb
Easy tests with Selenide and EasybEasy tests with Selenide and Easyb
Easy tests with Selenide and Easyb
 
Integration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDBIntegration Testing With ScalaTest and MongoDB
Integration Testing With ScalaTest and MongoDB
 
Testing ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NETTesting ASP.NET - Progressive.NET
Testing ASP.NET - Progressive.NET
 
Testing Ext JS and Sencha Touch
Testing Ext JS and Sencha TouchTesting Ext JS and Sencha Touch
Testing Ext JS and Sencha Touch
 
Kakunin E2E framework showcase
Kakunin E2E framework showcaseKakunin E2E framework showcase
Kakunin E2E framework showcase
 
Google Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and BeyondGoogle Back To Front: From Gears to App Engine and Beyond
Google Back To Front: From Gears to App Engine and Beyond
 
Google Play Services Rock
Google Play Services RockGoogle Play Services Rock
Google Play Services Rock
 
An Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using ProtractorAn Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using Protractor
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java side
 
Taming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and GebTaming Functional Web Testing with Spock and Geb
Taming Functional Web Testing with Spock and Geb
 
Automated acceptance test
Automated acceptance testAutomated acceptance test
Automated acceptance test
 
Qtp test
Qtp testQtp test
Qtp test
 

Mais de John Ferguson Smart Limited

My Reading Specs - Refactoring Patterns for Gherkin Scenarios
My Reading Specs - Refactoring Patterns for Gherkin ScenariosMy Reading Specs - Refactoring Patterns for Gherkin Scenarios
My Reading Specs - Refactoring Patterns for Gherkin ScenariosJohn Ferguson Smart Limited
 
Artisti e Condotierri - How can your team become artists of the 21st century ...
Artisti e Condotierri - How can your team become artists of the 21st century ...Artisti e Condotierri - How can your team become artists of the 21st century ...
Artisti e Condotierri - How can your team become artists of the 21st century ...John Ferguson Smart Limited
 
Engage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a differenceEngage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a differenceJohn Ferguson Smart Limited
 
Sustainable Test Automation with Serenity BDD and Screenplay
Sustainable Test Automation with Serenity BDD and ScreenplaySustainable Test Automation with Serenity BDD and Screenplay
Sustainable Test Automation with Serenity BDD and ScreenplayJohn Ferguson Smart Limited
 
Engage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a differenceEngage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a differenceJohn Ferguson Smart Limited
 
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...John Ferguson Smart Limited
 
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...John Ferguson Smart Limited
 
Screenplay - Next generation automated acceptance testing
Screenplay - Next generation automated acceptance testingScreenplay - Next generation automated acceptance testing
Screenplay - Next generation automated acceptance testingJohn Ferguson Smart Limited
 
All the world's a stage – the next step in automated testing practices
All the world's a stage – the next step in automated testing practicesAll the world's a stage – the next step in automated testing practices
All the world's a stage – the next step in automated testing practicesJohn Ferguson Smart Limited
 
It's Testing, Jim, but not as we know it - BDD for Testers
It's Testing, Jim, but not as we know it - BDD for TestersIt's Testing, Jim, but not as we know it - BDD for Testers
It's Testing, Jim, but not as we know it - BDD for TestersJohn Ferguson Smart Limited
 

Mais de John Ferguson Smart Limited (20)

My Reading Specs - Refactoring Patterns for Gherkin Scenarios
My Reading Specs - Refactoring Patterns for Gherkin ScenariosMy Reading Specs - Refactoring Patterns for Gherkin Scenarios
My Reading Specs - Refactoring Patterns for Gherkin Scenarios
 
Artisti e Condotierri - How can your team become artists of the 21st century ...
Artisti e Condotierri - How can your team become artists of the 21st century ...Artisti e Condotierri - How can your team become artists of the 21st century ...
Artisti e Condotierri - How can your team become artists of the 21st century ...
 
Engage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a differenceEngage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a difference
 
BE A POD OF DOLPHINS, NOT A DANCING ELEPHANT
BE A POD OF DOLPHINS, NOT A DANCING ELEPHANTBE A POD OF DOLPHINS, NOT A DANCING ELEPHANT
BE A POD OF DOLPHINS, NOT A DANCING ELEPHANT
 
Sustainable Test Automation with Serenity BDD and Screenplay
Sustainable Test Automation with Serenity BDD and ScreenplaySustainable Test Automation with Serenity BDD and Screenplay
Sustainable Test Automation with Serenity BDD and Screenplay
 
Feature Mapping Workshop
Feature Mapping WorkshopFeature Mapping Workshop
Feature Mapping Workshop
 
Engage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a differenceEngage! Bringing teams together to deliver software that makes a difference
Engage! Bringing teams together to deliver software that makes a difference
 
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
 
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
Beyond Given/When/Then - why diving into Cucumber is the wrong approach to ad...
 
Shift left-devoxx-pl
Shift left-devoxx-plShift left-devoxx-pl
Shift left-devoxx-pl
 
Screenplay - Next generation automated acceptance testing
Screenplay - Next generation automated acceptance testingScreenplay - Next generation automated acceptance testing
Screenplay - Next generation automated acceptance testing
 
Cucumber and Spock Primer
Cucumber and Spock PrimerCucumber and Spock Primer
Cucumber and Spock Primer
 
All the world's a stage – the next step in automated testing practices
All the world's a stage – the next step in automated testing practicesAll the world's a stage – the next step in automated testing practices
All the world's a stage – the next step in automated testing practices
 
CukeUp 2016 Agile Product Planning Workshop
CukeUp 2016 Agile Product Planning WorkshopCukeUp 2016 Agile Product Planning Workshop
CukeUp 2016 Agile Product Planning Workshop
 
BDD Anti-patterns
BDD Anti-patternsBDD Anti-patterns
BDD Anti-patterns
 
Serenity and the Journey Pattern
Serenity and the Journey PatternSerenity and the Journey Pattern
Serenity and the Journey Pattern
 
BDD - Collaborate like you mean it!
BDD - Collaborate like you mean it!BDD - Collaborate like you mean it!
BDD - Collaborate like you mean it!
 
BDD-Driven Microservices
BDD-Driven MicroservicesBDD-Driven Microservices
BDD-Driven Microservices
 
BDD Anti-patterns
BDD Anti-patternsBDD Anti-patterns
BDD Anti-patterns
 
It's Testing, Jim, but not as we know it - BDD for Testers
It's Testing, Jim, but not as we know it - BDD for TestersIt's Testing, Jim, but not as we know it - BDD for Testers
It's Testing, Jim, but not as we know it - BDD for Testers
 

Último

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Último (20)

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

BDD, ATDD, Page Objects: The Road to Sustainable Web Testing

  • 1. BDD, ATDD, Page Objects The Road to Sustainable Web Testing John Ferguson Smart
  • 2. So who is this guy, anyway? Consulta nt Trainer Mentor Author Speaker Coder John Fer guson S mar t
  • 3. Java Power Tools Bootcamp at Skills Matter ALL YOUR AGILE JAVA TOOLS TRAINING ARE BELONG TO US bDr iver m  2/We mave Seleniu Hudson n BDD JUnit TD D London January 24-28 2011
  • 4. Don’t let your web tests end up like this!
  • 5. The Three Ways of Automated Web Testing Record/Replay Scripting Page Objects
  • 8. Script-based automated tests Selenium RC HTMLUnit JWebUnit Canoe Webtest Watir
  • 9. Script-based automated tests Selenium RC HTMLUnit JWebUnit Canoe Webtest Watir
  • 10. What we’d like to have... D.R.Y Don’t Repeat Yourself
  • 11. What we’d like to have... Reusable building blocks
  • 12. What we’d like to have... A communication tool
  • 13. Introducing Page Objects Reusable Low maintenance Speak your language
  • 14. Page Objects are reusable components
  • 15. Page Objects hide unnecessary details
  • 16. Page Objects are low maintenance
  • 17. Page Objects speak everybody’s language
  • 18. Page Objects in action An example
  • 19. Page Objects in action The old way - Selenium RC selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com/"); selenium.open("http://www.google.com"); selenium.waitForPageToLoad(5000); selenium.type("q", "cats"); selenium.click("BtnG"); selenium.waitForPageToLoad(5000); assertThat(selenium.isTextPresent("cats"), is(true));
  • 20. Page Objects in action The new way - Using Page Objects WebDriver driver = new FirefoxDriver(); GoogleSearchPage page = new GoogleSearchPage(driver); page.open(); page.searchFor("cats"); assertThat(page.getTitle(), containsString("cats") ); page.close();
  • 21. Page Objects in action The new way - Using Page Objects WebDriver driver = new FirefoxDriver(); GoogleSearchPage page = new GoogleSearchPage(driver); page.open(); page.searchFor("cats"); assertThat(page.getTitle(), containsString("cats") ); page.close(); GoogleSearchPage open() close() searchFor( query : String ) clickOnFeelingLucky() openAdvancedSearchOptions() ...
  • 22. Page Objects in action The new way - another example WebDriver driver = new FirefoxDriver(); GoogleSearchPage page = new GoogleSearchPage(driver); Hides HTML page.open() details page.typeIntoSearchBox("cats"); List<String> suggestions = page.getSuggestions(); Uses assertThat(suggestions, hasItem("cats and dogs")); business terms page.close();
  • 23. From Pages Objects to BDD Taking expressive tests to the next level
  • 24. BDD in action WebDriver driver = new FirefoxDriver(); GoogleSearchPage page = new GoogleSearchPage(driver); page.open() page.typeIntoSearchBox("cats"); List<String> suggestions = page.getSuggestions(); assertThat(suggestions, hasItem("cats and dogs")); page.close(); But would your testers understand this?
  • 25. BDD in action Much more readable using "google-search" scenario "Searching for 'cats' on Google", { when "the user types 'cats' in the search box", { onTheWebPage.typeIntoSearchBox "cats" } then "the drop-down suggestions should include 'cats and dogs'" theWebPage.suggestions.shouldHave "cats and dogs" } } Still uses Page Objects under the hood How about this?
  • 26. BDD in action More readable reporting
  • 27. So how does it work? Easyb Plugin using "google-search" scenario "Searching for 'cats' on Google",{ when "the user types 'cats' in the search box", { onTheWebPage.typeIntoSearchBox "cats" } then "the drop-down suggestions should include 'cats and dogs'" theWebPage.suggestions.shouldHave "cats and dogs" } } Page Objects Page Navigation
  • 28. Automated Acceptance Tests Where are your goal posts?
  • 29. Automated Acceptance Tests Unit tests are for Acceptance tests are developers for everyone else
  • 30. Automated Acceptance Tests Unit tests are for Acceptance tests are developers for everyone else
  • 31. Automated Acceptance Tests Passing acceptance tests Pending acceptance tests
  • 32. Automated Acceptance Tests Acceptance tests Pending acceptance tests
  • 33. Automated Acceptance Tests tags ["acceptance", "sprint-1"] Implement these in scenario "An empty grid should produce an empty grid",{ Sprint 1 when "the user chooses to start a new game", { newGamePage = homePage.clickOnNewGameLink() } then "the user is invited to enter the initial state of the universe", { newGamePage.text.shouldHave "Please seed your universe" } } scenario "The user can seed the universe with an initial grid",{ given "the user is on the new grid page", { newGridPage = homePage.clickOnNewGameLink() } when "that the user clicks on Go without picking any cells", { gridDisplayPage = newGridPage.clickOnGoButton() } then "the application will display an empty universe", { String[][] anEmptyGrid = [[".", ".", "."], [".", ".", "."], [".", ".", "."]] gridDisplayPage.displayedGrid.shouldBe anEmptyGrid } }
  • 34. And now for the case studies
  • 35. Case Study Government online form processing
  • 36. Architecture - fitting it all together Acceptance tests Easyb Plugin Page Objects Integration tests JUnit Web Application
  • 37. The application Perl and Java Lots of forms Ugly colours
  • 38. What the tester uses using "ecert" Custom easyb plugin tags "TC02" Plugin handles before "we are connected to the UAT environment", { authentication given "we are connected to the UAT environment", { connecting.to('uat').withUser('a_tester') } } Business-level tests scenario "The user opens the 'New Export Certificate' page and selects a country",{ when "the user clicks on the 'New Export Certificate' menu", { onTheWebPage.navigationPanel.clickOnNewExportCertificate() } and "the user chooses USA and clicks on 'Show Data Entry'", { onTheWebPage.selectDeclarationFormFor 'United States' } then "we should be on the US Export Certification Preparation page", { theWebPage.asText.shouldHave "Export Certificate Preparation" theWebPage.asText.shouldHave "Declarations for United States" } and "the 'Raise New Blank Export Certificate' is default and selected", { theWebPage.raiseNewBlankCertificate.shouldBeSelected() } }
  • 40. What the tester uses ... scenario "The user fills in the Export Certificate Submission Form",{ when "we fill in the export certificate details", { theWebPage.with { certificateNumber = '123456' consignor = 'LANEXCO1' importerID = '123' Groovy shortcuts importerName = 'ImportsRUs' importerRepresentative = 'local guy' officialInformation = 'very important' transportMode = 'AIR' carrierName = 'AirNZ' Business-level tests productItem(1).description = 'Product data' productItem(1).harmonizedSystemCode = '020110' productItem(1).with { process(1).with { type = 'Freezing' processingStartDate = '01/01/2010' Handling processingEndDate = '02/01/2010' nested forms appliedBy = 'some dude' overrideSelected() } ...
  • 41. What the Page Objects look like public class ECertNavigationPanel extends AuthenticatedWebPage { @FindBy(linkText="XML Submit") WebElement xmlSubmit; WebDriver annotations @FindBy(linkText="New Export Certificate") WebElement newExportCertificate; public ECertNavigationPanel(WebDriver driver) { super(driver); } public WebElement getXmlSubmit() {...} public WebElement getNewExportCertificate() {...} public ECertSubmitXmlPage clickOnXmlSubmit() {...} public ExportCertificatePreparationPage clickOnNewExportCertificate() {...} }
  • 42. Case Study Class Report An online reporting tool for lawyers h"p://customfirst.com
  • 43. Architecture - fitting it all together Regression/ Integration tests Page Objects Web Application
  • 44. The application RUI Application Lots of AJAX !
  • 45. What the tests look like @Mixin (SeleniumTest) class ReportViewerTests extends AbstractSeleniumBaseTest { ViewerPage viewerPage Setting up the public void setUp() { super.setUp() Page Object TestFixtures.loadData() viewerPage = new ViewerPage(selenium, contextPath) viewerPage.openHomePage() } public void testClickingGLReportsIconShouldDisplaySubFolders() { viewerPage.clickFolderOpenIcon("GL Reports") assertTrue viewerPage.folderPresent("Accounts") Testing the app assertTrue viewerPage.folderPresent("Test Reports") } public void testClickingOnASubFolderShouldDisplayReports() { viewerPage.clickFolderOpenIcon("GL Reports") assertTrue viewerPage.folderPresent("Test Reports") viewerPage.clickFolder "Test Reports" assertTrue viewerPage.reportRowPresent("Test Reports","Aged Debtors By Client") assertTrue viewerPage.reportRowPresent("Test Reports","Chart") } ...
  • 46. What the Page Objects look like class ViewerPage extends AbstractPageObject{ public ViewerPage(def selenium, def contextPath) { Business-friendly super(selenium, contextPath) } methods public void clickFolder(String folderName) {...} public void clickFolderOpenIcon(String folderId) {...} public boolean folderPresent(String folderName){...} public boolean reportRowPresent(String folder,String rowName){...} public boolean reportParameterPresent(String reportName,String parameterName){...} public boolean reportRowTextPresent(String folder,String reportName,String text){...} ...
  • 48. The application Looks a bit like this one... (but more complex) (and top secret) (Shhhhhh!) Again, lots of AJAX !
  • 49. Page Components Reusable component class RadioButton { WebElement button WebElement buttonContainer; def buttonId def driver void clickButton() { initButton() button.click(); } void shouldBeEnabled() { assert !isDisabled(); } void shouldBeDisabled() { assert isDisabled(); } Horrible nasty GWT code private boolean isDisabled() { initButton() return buttonContainer.getAttribute("class").contains("x-item-disabled"); } private void initButton() { if (button==null) { buttonContainer=driver.findElement(By.id("gwt-debug-${buttonId}_BUTTON")); button=driver.findElement(By.xpath("//input[contains(@value, ${buttonId}-input)]")); } } }
  • 50. Page Components @Test public void userShouldBecomeOwnerOfCurrentWorkItem() { page.workItemTree.selectEntryCalled("Stuff to do") ... page.assignButton.shouldBeEnabled() page.assignButton.click(); Click on a button page.assignButton.shouldBeHidden(); page.retryButton.shouldBeEnabled(); page.saveButton.shouldBeDisabled() page.saveButton.shouldBePresent(); Custom asserts } scenario "No work items should initially appear on the screen",{ when "the user opens the page", { page.open() } and "the Item Tree 'Show all' check box should not be ticked", { assert page.itemTree.showAll.isNotChecked() } and "the Item Tree should contain no work items", { assert page.itemTree.isEmpty() } } BDD-style tests
  • 51. Page Components class Grid { A Grid (table) component def driver def gridId def getAt(int i) { It looks like an array def gridRows = getGridRows() return gridRows[i] } def size() { def gridRows = getGridRows() return gridRows.size() } def shouldHaveARowWith(def map) { def gridRows = getGridRows() def matchingRowFound = true for(entry in map) { def gridRow = gridRows.find { row -> row[entry.key] == entry.value } matchingRowFound = gridRow != null } return matchingRowFound }
  • 52. Page Components @Test void theSummaryItemChangesToReflectTreeChoice() { page.itemTree.selectEntryCalled("Stuff to do") This is not an array assert page.itemSummaryGrid.size() == 1 def highlightedItemSummaryRow = page.itemSummaryGrid[0] assert highlightedItemSummaryRow.customerName == "ACME Inc" }
  • 53. ATDD, BDD and Page Objects Clean, precise, well-designed Powerful, robust, low-maintenance John  Ferguson  Smart Email:  john.smart@wakaleo.com Web:  h"p://www.wakaleo.com Twi"er:  wakaleo