SlideShare a Scribd company logo
1 of 14
Download to read offline
Agile Acceptance Tests

bdd, cucumber, cuke4duke, groovy,
       selenium2, webdriver



                         Richard Paul, June 2010
Behaviour Driven Development (BDD)

  Feature
  In order to ...
  As a ...
  I want ...

  Scenario
  Given ...
  When ...
  Then ...



This is just a small part of BDD directly related to acceptance testing.
Cucumber

BDD testing framework written in Ruby



             Cucumber + JRuby + Cuke4Duke

                             =

             BDD testing framework for the JVM


Languages: Groovy, Java, Scala, Javascript, Ioke, Ruby
Frameworks: Spring, Guice, WebDriver, Maven, Ant
Kick Start

$ git clone http://github.com/aslakhellesoy/cuke4duke.git
$ cd examples/groovy-webdriver
$ mvn integration-test




The first time you run a version of Cucumber you need to install the Ruby
gems:
$ mvn -Dcucumber.installGems=true cuke4duke:cucumber

Warnings: Bleeding edge. First run will download a lot of dependencies.
Syntax - Gherkin




Steps
Given - Set up the context
When - Perform an action
Then - Verify outcome
Can use And to chain additional steps of the same type
Running Cucumber

$ mvn integration-test (Maven phase)
$ mvn cuke4duke:cucumber (Maven goal)
Automation - Step Definitions
Where does browser come from?
GroovyDsl

Given(~'repeated d+ times') { times ->
  // check something appears x times
}
Same applies for When, Then, And
Before('tag') {
  // run code before a scenario
}
After('tag') {
  // run code after a scenario
}
World() {
  // see http://bit.ly/davWpW for more details
}
Selenium 2 - WebDriver

Selenium 2 is the melding of Selenium and the WebDriver API

browser = new FirefoxDriver() // Or IE etc
browser.get('http://example.com')
browser.findElementByClassName('navigation')
browser.findElementsByCssSelector('#results li')
findElementByXXX returns a WebElement for first match
findElementsByXXX return a collection of matches

element.text // getText() in Java
element.click()
element.sendKeys('type something')
element.value
element.selected
element.getAttribute('href')
Groovyisms - Collections

<ul>
 <li>1</li>
 <li>2</li>
 <li>3</li>
</ul>

def elements = browser.findElementsByTagName('li')
elements.text
> ['1', '2', '3']

// Check the numbers increase
elements.eachWithIndex { element, i ->
  assertThat(element.text, is(i + ''))
}
When? Why?

 Acceptance tests are written up front
 Defines the scenarios you need to code
 Facilitates discussion on different scenarios
 Once green you are done
 Leads to no unnecessary code (YAGNI)
 Acceptance criteria automatically becomes regression suite



                 Amber > Red > Green
               Pending > Failing > Passing
How?

    Acceptance tests are first class artifacts
    Keep code DRY by reusing steps
    Refactor steps to keep them clean
    Focus on actions not tasks

Good
Given I am signed in as an administrator
When I view the list of signed in users
Then I should see ...

Bad (unless you are trying to test sign in)
Given I am on the home page
And I click 'Sign in'
And I fill in username with 'admin'
And I fill in password with 'secret'
And I press 'Sign in'
Links

http://cukes.info/
http://wiki.github.com/aslakhellesoy/cuke4duke/
http://github.com/tpope/vim-cucumber
http://selenium.googlecode.com/svn/trunk/docs/api/java/index.html
http://www.rapaul.com/tag/bdd/

Cucumber photo (creative commons) http://www.flickr.com/photos/vizzzual-dot-
com/2738586453/



                                 Thanks!
Richard Paul
http://rapaul.com
@rapaul

More Related Content

What's hot

Angular workflow with gulp.js
Angular workflow with gulp.jsAngular workflow with gulp.js
Angular workflow with gulp.js
Cihad Horuzoğlu
 

What's hot (20)

Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScript
 
Jenkins Plugin Development With Gradle And Groovy
Jenkins Plugin Development With Gradle And GroovyJenkins Plugin Development With Gradle And Groovy
Jenkins Plugin Development With Gradle And Groovy
 
Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS Superfast Automated Web Testing with CasperJS & PhantomJS
Superfast Automated Web Testing with CasperJS & PhantomJS
 
Angular workflow with gulp.js
Angular workflow with gulp.jsAngular workflow with gulp.js
Angular workflow with gulp.js
 
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
[Image Results] Java Build Tools: Part 2 - A Decision Maker's Guide Compariso...
 
Groovy Maven Builds
Groovy Maven BuildsGroovy Maven Builds
Groovy Maven Builds
 
Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜
Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜
Jenkins 2.0 最新事情 〜Make Jenkins Great Again〜
 
Front-end development automation with Grunt
Front-end development automation with GruntFront-end development automation with Grunt
Front-end development automation with Grunt
 
Writing a Jenkins / Hudson plugin
Writing a Jenkins / Hudson pluginWriting a Jenkins / Hudson plugin
Writing a Jenkins / Hudson plugin
 
Grunt & Front-end Workflow
Grunt & Front-end WorkflowGrunt & Front-end Workflow
Grunt & Front-end Workflow
 
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
 
Grunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerGrunt - The JavaScript Task Runner
Grunt - The JavaScript Task Runner
 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
 
Front-end tools
Front-end toolsFront-end tools
Front-end tools
 
How we maintain 200+ Drupal sites in Georgetown University
How we maintain 200+ Drupal sites in Georgetown UniversityHow we maintain 200+ Drupal sites in Georgetown University
How we maintain 200+ Drupal sites in Georgetown University
 
Frontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the likeFrontend JS workflow - Gulp 4 and the like
Frontend JS workflow - Gulp 4 and the like
 
Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 
Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!Forget Grunt and Gulp! Webpack and NPM rule them all!
Forget Grunt and Gulp! Webpack and NPM rule them all!
 
Devenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.jsDevenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.js
 
Introduction to Gulp
Introduction to GulpIntroduction to Gulp
Introduction to Gulp
 

Viewers also liked

Abusing bleeding edge web standards for appsec glory
Abusing bleeding edge web standards for appsec gloryAbusing bleeding edge web standards for appsec glory
Abusing bleeding edge web standards for appsec glory
Priyanka Aash
 
Memory forensics using VMI for cloud computing
Memory forensics using VMI for cloud computingMemory forensics using VMI for cloud computing
Memory forensics using VMI for cloud computing
Priyanka Aash
 
Attacking SDN infrastructure: Are we ready for the next gen networking
Attacking SDN infrastructure: Are we ready for the next gen networkingAttacking SDN infrastructure: Are we ready for the next gen networking
Attacking SDN infrastructure: Are we ready for the next gen networking
Priyanka Aash
 
Intra process memory protection for applications on ARM and x86
Intra process memory protection for applications on ARM and x86Intra process memory protection for applications on ARM and x86
Intra process memory protection for applications on ARM and x86
Priyanka Aash
 

Viewers also liked (17)

Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby Conference
 
The Road to the Cloud
The Road to the CloudThe Road to the Cloud
The Road to the Cloud
 
Hardening AWS environment and automating incidence response for AWS cmpromises
Hardening AWS environment and automating incidence response for AWS cmpromisesHardening AWS environment and automating incidence response for AWS cmpromises
Hardening AWS environment and automating incidence response for AWS cmpromises
 
More than just what you have learnt: Your ePortfolio=learnt + love+created-Ch...
More than just what you have learnt: Your ePortfolio=learnt + love+created-Ch...More than just what you have learnt: Your ePortfolio=learnt + love+created-Ch...
More than just what you have learnt: Your ePortfolio=learnt + love+created-Ch...
 
Abusing bleeding edge web standards for appsec glory
Abusing bleeding edge web standards for appsec gloryAbusing bleeding edge web standards for appsec glory
Abusing bleeding edge web standards for appsec glory
 
How Crownbet Disrupted the Australian Market, One Instance at a Time - Sessio...
How Crownbet Disrupted the Australian Market, One Instance at a Time - Sessio...How Crownbet Disrupted the Australian Market, One Instance at a Time - Sessio...
How Crownbet Disrupted the Australian Market, One Instance at a Time - Sessio...
 
Memory forensics using VMI for cloud computing
Memory forensics using VMI for cloud computingMemory forensics using VMI for cloud computing
Memory forensics using VMI for cloud computing
 
Attacking SDN infrastructure: Are we ready for the next gen networking
Attacking SDN infrastructure: Are we ready for the next gen networkingAttacking SDN infrastructure: Are we ready for the next gen networking
Attacking SDN infrastructure: Are we ready for the next gen networking
 
Reflection paper
Reflection paperReflection paper
Reflection paper
 
Hardware Attacks and Security
Hardware Attacks and SecurityHardware Attacks and Security
Hardware Attacks and Security
 
AngularConf2016 - A leap of faith !?
AngularConf2016 - A leap of faith !?AngularConf2016 - A leap of faith !?
AngularConf2016 - A leap of faith !?
 
Taking Speed out of the Equation - Session Sponsored by TPG Telecom
Taking Speed out of the Equation - Session Sponsored by TPG TelecomTaking Speed out of the Equation - Session Sponsored by TPG Telecom
Taking Speed out of the Equation - Session Sponsored by TPG Telecom
 
Intra process memory protection for applications on ARM and x86
Intra process memory protection for applications on ARM and x86Intra process memory protection for applications on ARM and x86
Intra process memory protection for applications on ARM and x86
 
Unit 5 - Predicates
Unit 5 - PredicatesUnit 5 - Predicates
Unit 5 - Predicates
 
Chapter i dream have a meaning
Chapter i dream have a meaningChapter i dream have a meaning
Chapter i dream have a meaning
 
Letter of Credit 101
Letter of Credit 101Letter of Credit 101
Letter of Credit 101
 
The Lean Startup Basics and Intro for Beginners
The Lean Startup Basics and Intro for BeginnersThe Lean Startup Basics and Intro for Beginners
The Lean Startup Basics and Intro for Beginners
 

Similar to Acceptance tests

What the heck went wrong?
What the heck went wrong?What the heck went wrong?
What the heck went wrong?
Andy McKay
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new build
Igor Khotin
 

Similar to Acceptance tests (20)

greach 2014 marco vermeulen bdd using cucumber jvm and groovy
greach 2014 marco vermeulen bdd using cucumber jvm and groovygreach 2014 marco vermeulen bdd using cucumber jvm and groovy
greach 2014 marco vermeulen bdd using cucumber jvm and groovy
 
Test Driven In Groovy
Test Driven In GroovyTest Driven In Groovy
Test Driven In Groovy
 
What the heck went wrong?
What the heck went wrong?What the heck went wrong?
What the heck went wrong?
 
Session on Launching Selenium Grid and Running tests using docker compose and...
Session on Launching Selenium Grid and Running tests using docker compose and...Session on Launching Selenium Grid and Running tests using docker compose and...
Session on Launching Selenium Grid and Running tests using docker compose and...
 
From devOps to front end Ops, test first
From devOps to front end Ops, test firstFrom devOps to front end Ops, test first
From devOps to front end Ops, test first
 
End-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystemEnd-to-end web-testing in ruby ecosystem
End-to-end web-testing in ruby ecosystem
 
Introduction To Maven2
Introduction To Maven2Introduction To Maven2
Introduction To Maven2
 
Introduction to JIB and Google Cloud Run
Introduction to JIB and Google Cloud RunIntroduction to JIB and Google Cloud Run
Introduction to JIB and Google Cloud Run
 
Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration Continuous Delivery, Continuous Integration
Continuous Delivery, Continuous Integration
 
Attack Chaining: Advanced Maneuvers for Hack Fu
Attack Chaining: Advanced Maneuvers for Hack FuAttack Chaining: Advanced Maneuvers for Hack Fu
Attack Chaining: Advanced Maneuvers for Hack Fu
 
Autotests introduction - Codeception + PHP Basics
Autotests introduction - Codeception + PHP BasicsAutotests introduction - Codeception + PHP Basics
Autotests introduction - Codeception + PHP Basics
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Automation Zaman Now
Automation Zaman NowAutomation Zaman Now
Automation Zaman Now
 
Gradle - time for a new build
Gradle - time for a new buildGradle - time for a new build
Gradle - time for a new build
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 
Stop Being Lazy and Test Your Software
Stop Being Lazy and Test Your SoftwareStop Being Lazy and Test Your Software
Stop Being Lazy and Test Your Software
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle Story
 
Security testing of YUI powered applications
Security testing of YUI powered applicationsSecurity testing of YUI powered applications
Security testing of YUI powered applications
 
Test Driven Development with Chef
Test Driven Development with ChefTest Driven Development with Chef
Test Driven Development with Chef
 
Continous Delivering a PHP application
Continous Delivering a PHP applicationContinous Delivering a PHP application
Continous Delivering a PHP application
 

More from Richard Paul (8)

Cucumber on the JVM with Groovy
Cucumber on the JVM with GroovyCucumber on the JVM with Groovy
Cucumber on the JVM with Groovy
 
jQuery Behaviours
jQuery BehavioursjQuery Behaviours
jQuery Behaviours
 
Introduction to Spring's Dependency Injection
Introduction to Spring's Dependency InjectionIntroduction to Spring's Dependency Injection
Introduction to Spring's Dependency Injection
 
Introduction to Spring MVC
Introduction to Spring MVCIntroduction to Spring MVC
Introduction to Spring MVC
 
Unit Testing Fundamentals
Unit Testing FundamentalsUnit Testing Fundamentals
Unit Testing Fundamentals
 
Using Dojo
Using DojoUsing Dojo
Using Dojo
 
Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax Basics
 
Mocking in Java with Mockito
Mocking in Java with MockitoMocking in Java with Mockito
Mocking in Java with Mockito
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

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
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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
 
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
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
[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
 
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...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Acceptance tests

  • 1. Agile Acceptance Tests bdd, cucumber, cuke4duke, groovy, selenium2, webdriver Richard Paul, June 2010
  • 2. Behaviour Driven Development (BDD) Feature In order to ... As a ... I want ... Scenario Given ... When ... Then ... This is just a small part of BDD directly related to acceptance testing.
  • 3. Cucumber BDD testing framework written in Ruby Cucumber + JRuby + Cuke4Duke = BDD testing framework for the JVM Languages: Groovy, Java, Scala, Javascript, Ioke, Ruby Frameworks: Spring, Guice, WebDriver, Maven, Ant
  • 4. Kick Start $ git clone http://github.com/aslakhellesoy/cuke4duke.git $ cd examples/groovy-webdriver $ mvn integration-test The first time you run a version of Cucumber you need to install the Ruby gems: $ mvn -Dcucumber.installGems=true cuke4duke:cucumber Warnings: Bleeding edge. First run will download a lot of dependencies.
  • 5. Syntax - Gherkin Steps Given - Set up the context When - Perform an action Then - Verify outcome Can use And to chain additional steps of the same type
  • 6. Running Cucumber $ mvn integration-test (Maven phase) $ mvn cuke4duke:cucumber (Maven goal)
  • 7. Automation - Step Definitions
  • 8. Where does browser come from?
  • 9. GroovyDsl Given(~'repeated d+ times') { times -> // check something appears x times } Same applies for When, Then, And Before('tag') { // run code before a scenario } After('tag') { // run code after a scenario } World() { // see http://bit.ly/davWpW for more details }
  • 10. Selenium 2 - WebDriver Selenium 2 is the melding of Selenium and the WebDriver API browser = new FirefoxDriver() // Or IE etc browser.get('http://example.com') browser.findElementByClassName('navigation') browser.findElementsByCssSelector('#results li') findElementByXXX returns a WebElement for first match findElementsByXXX return a collection of matches element.text // getText() in Java element.click() element.sendKeys('type something') element.value element.selected element.getAttribute('href')
  • 11. Groovyisms - Collections <ul> <li>1</li> <li>2</li> <li>3</li> </ul> def elements = browser.findElementsByTagName('li') elements.text > ['1', '2', '3'] // Check the numbers increase elements.eachWithIndex { element, i -> assertThat(element.text, is(i + '')) }
  • 12. When? Why? Acceptance tests are written up front Defines the scenarios you need to code Facilitates discussion on different scenarios Once green you are done Leads to no unnecessary code (YAGNI) Acceptance criteria automatically becomes regression suite Amber > Red > Green Pending > Failing > Passing
  • 13. How? Acceptance tests are first class artifacts Keep code DRY by reusing steps Refactor steps to keep them clean Focus on actions not tasks Good Given I am signed in as an administrator When I view the list of signed in users Then I should see ... Bad (unless you are trying to test sign in) Given I am on the home page And I click 'Sign in' And I fill in username with 'admin' And I fill in password with 'secret' And I press 'Sign in'