SlideShare a Scribd company logo
Web Automation in BDD
SpecFlow + WatiN
What about me?
2
What about you?
• Who is doing test automation?
• Who is using open source Selenium or WatiN?
• Who is practicing BDD with SpecFlow or
Cucumber or other BDD tool?
3
Agenda
• BDD Introduction
• Demo
• BDD Test Framework (SpecFlow + WatiN)
• Test design patterns/practices
4
Behaviour Driven Development
 One of many agile development techniques
 Specification driven by examples
 Clear communication between domain experts, developers, testers and
customers
BDD is an agile software development technique that
encourages collaboration between developers, QA, and non-
technical or business participants in a software project. It's
more about business specifications than about tests. You
write a specification for a story and verify whether the specs
work as expected.
5
BDD Examples
Feature: Serve coffee
In order to earn money
Customers should be able to
buy coffee at all times
Scenario: Buy last coffee
Given there are 1 coffee left in the machine
And I have deposited 1$
When I press the coffee button
Then I should be served a coffee
[Test]
public void TestCoffeeMachine()
{
// Some test codes here
}
BDD vs TDD
BDD Tools
BDD Languages - Gherkin
• Domain Specific Language
• Easy to understand by customers
• Simple with few keywords
– Feature
– Scenario, Scenario Outline
– Given, When, Then
• Localized to 35+ languages
Scenario: GIVEN, WHEN, THEN
10
BDD Framework
11
How SpecFlow Works?
Drives
GUI
• Demo 1: Coffee Machine
13
• Demo 2: Google Search (Compare with WatiN Hello World example)
14
SpecFlow - Step Argument
• Step definition: use regular expression to eliminate duplicate script
15
SpecFlow - Table argument
16
SpecFlow - Context
17
Data Sharing between steps/scenarios
SpecFlow - Test Fixture
• BeforeFeature/BeforeScenario: Precondition of each
feature/scenario
• AfterFeature/AfterScenario: Teardown or cleanup after test
execution
• Tags
SpecFlow - Scenario Outline (Data Driven)
Scenario: TC1 Add two numbers
Given I have entered 1 into the calculator
And I have entered 2 into the calculator
When I press add
Then the result should be 3 on the screen
Scenario: TC2 Add two numbers
Given I have entered 2 into the calculator
And I have entered 2 into the calculator
When I press add
Then the result should be 4 on the screen
Data driven on scenarios.
From framework to platform
• Test Report/Test Log
21
Nunit
TestResults.txt
TestResults.xml
SpecificationResults.html
SpecFlow
• Test environment
• Continuous build
Patterns and Practices
• Domain Driven Design
• Singleton
• Page object pattern
• Driver pattern
• Reusable modules
22
Domain Driven Design
• Express your tests in the language of the end-user of the app.
23


Web Browser in Singleton Mode
public static class WebBrowser
{
public static IE Current
{
get {
if (!ScenarioContext.Current.ContainsKey("browser"))
ScenarioContext.Current["browser"] = new IE();
return ScenarioContext.Current["browser"] as IE;
}
}
}
24
Page Object Pattern
• A simple abstraction of the UI of your web app.
25
Driver Pattern
• Driver object defines all actions/events among
current page
26
Reusable Modules
27
Summary
• BDD Concept
• SpecFlow Test Framework
• Web Automation Practice
28
The framework and pattern matters, not the tools 
Reference
• Specification by Examples - http://specificationbyexample.com/
• MSDN article on BDD: http://msdn.microsoft.com/en-
us/magazine/gg490346.aspx
• BDD from NDC: http://vimeo.com/43536443
• WATIN and more: http://watinandmore.blogspot.com/
29
Questions? 
Suggestions? 
Thank you! 
- 余宗宝(@Sandyshow)
zbyu81@hotmail.com

More Related Content

PDF
BDD in Java using Cucumber
PPTX
BDD / cucumber /Capybara
PPT
Testing Any Site With Cucumber and Selenium
PDF
Behavior Driven Development and Automation Testing Using Cucumber
PDF
Selenium Tips & Tricks - StarWest 2015
PPTX
Learn SoapUI
PDF
Behavior Driven Development with Cucumber
PPTX
Behavior Driven Development Testing (BDD)
BDD in Java using Cucumber
BDD / cucumber /Capybara
Testing Any Site With Cucumber and Selenium
Behavior Driven Development and Automation Testing Using Cucumber
Selenium Tips & Tricks - StarWest 2015
Learn SoapUI
Behavior Driven Development with Cucumber
Behavior Driven Development Testing (BDD)

What's hot (19)

PDF
Implementing Testing for Behavior-Driven Development Using Cucumber
PDF
Selenium RC: Automated Testing of Modern Web Applications
PPT
Behavior Driven Development (BDD) and Agile Testing
PDF
Tips and Tricks For Faster Asp.NET and MVC Applications
PPTX
Selenium for Jobseekers
PPT
Ajax & ASP.NET 2
PDF
Scalable web application architecture
PDF
Using Selenium to Improve a Teams Development Cycle
PDF
How to Use Selenium, Successfully
PPTX
Automation solution using jbehave, selenium and hudson
PPTX
Measuring web performance
PPTX
Test automation with Cucumber-JVM
PPTX
Enough with the javas cript already! de Nicholas Zakas
PPTX
Enable Domino Data Access Services (DAS)
PDF
webcomponents (Jfokus 2015)
PDF
Esri Dev Summit 2009 Rest and Mvc Final
PPTX
Chanhao Jiang And David Wei Presentation Quickling Pagecache
PPTX
Building ColdFusion And AngularJS Applications
PDF
RESTful services and OAUTH protocol in IoT
Implementing Testing for Behavior-Driven Development Using Cucumber
Selenium RC: Automated Testing of Modern Web Applications
Behavior Driven Development (BDD) and Agile Testing
Tips and Tricks For Faster Asp.NET and MVC Applications
Selenium for Jobseekers
Ajax & ASP.NET 2
Scalable web application architecture
Using Selenium to Improve a Teams Development Cycle
How to Use Selenium, Successfully
Automation solution using jbehave, selenium and hudson
Measuring web performance
Test automation with Cucumber-JVM
Enough with the javas cript already! de Nicholas Zakas
Enable Domino Data Access Services (DAS)
webcomponents (Jfokus 2015)
Esri Dev Summit 2009 Rest and Mvc Final
Chanhao Jiang And David Wei Presentation Quickling Pagecache
Building ColdFusion And AngularJS Applications
RESTful services and OAUTH protocol in IoT
Ad

Similar to Web automation in BDD (20)

PPTX
Intro to Automation Using Perfecto's CQ Lab
PDF
Model-based Testing: Taking BDD/ATDD to the Next Level
PDF
Automated Browser Testing
PDF
End to-end test automation at scale
PDF
StarWest 2019 - End to end testing: Stupid or Legit?
PDF
Start with version control and experiments management in machine learning
PDF
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
PDF
Nexmark with beam
PPTX
Cucumber_Training_ForQA
PDF
Continuous Integration for z using Test Data Management and Application D...
PDF
Presentation Verification & Validation
PPTX
Technical Without Code
PDF
Delivery Pipelines as a First Class Citizen @deliverAgile2019
PPTX
MSF: Sync your Data On-Premises And To The Cloud - dotNetwork Gathering, Oct ...
PPTX
Advanced Coded UI Testing
PDF
Lecture #6. automation testing (andrey oleynik)
PDF
Introduction to DevOps
PPTX
Test AI/ML Applications
PDF
Software Testing - Online Guide
PPTX
Staying Close to Experts with Executable Specifications
Intro to Automation Using Perfecto's CQ Lab
Model-based Testing: Taking BDD/ATDD to the Next Level
Automated Browser Testing
End to-end test automation at scale
StarWest 2019 - End to end testing: Stupid or Legit?
Start with version control and experiments management in machine learning
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
Nexmark with beam
Cucumber_Training_ForQA
Continuous Integration for z using Test Data Management and Application D...
Presentation Verification & Validation
Technical Without Code
Delivery Pipelines as a First Class Citizen @deliverAgile2019
MSF: Sync your Data On-Premises And To The Cloud - dotNetwork Gathering, Oct ...
Advanced Coded UI Testing
Lecture #6. automation testing (andrey oleynik)
Introduction to DevOps
Test AI/ML Applications
Software Testing - Online Guide
Staying Close to Experts with Executable Specifications
Ad

Recently uploaded (20)

PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Encapsulation theory and applications.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Electronic commerce courselecture one. Pdf
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
MYSQL Presentation for SQL database connectivity
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
NewMind AI Weekly Chronicles - August'25 Week I
Network Security Unit 5.pdf for BCA BBA.
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Understanding_Digital_Forensics_Presentation.pptx
Machine learning based COVID-19 study performance prediction
Diabetes mellitus diagnosis method based random forest with bat algorithm
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation_ Review paper, used for researhc scholars
Unlocking AI with Model Context Protocol (MCP)
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Encapsulation theory and applications.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
“AI and Expert System Decision Support & Business Intelligence Systems”
The AUB Centre for AI in Media Proposal.docx
Advanced methodologies resolving dimensionality complications for autism neur...
Electronic commerce courselecture one. Pdf
Building Integrated photovoltaic BIPV_UPV.pdf
MYSQL Presentation for SQL database connectivity

Web automation in BDD

  • 1. Web Automation in BDD SpecFlow + WatiN
  • 3. What about you? • Who is doing test automation? • Who is using open source Selenium or WatiN? • Who is practicing BDD with SpecFlow or Cucumber or other BDD tool? 3
  • 4. Agenda • BDD Introduction • Demo • BDD Test Framework (SpecFlow + WatiN) • Test design patterns/practices 4
  • 5. Behaviour Driven Development  One of many agile development techniques  Specification driven by examples  Clear communication between domain experts, developers, testers and customers BDD is an agile software development technique that encourages collaboration between developers, QA, and non- technical or business participants in a software project. It's more about business specifications than about tests. You write a specification for a story and verify whether the specs work as expected. 5
  • 6. BDD Examples Feature: Serve coffee In order to earn money Customers should be able to buy coffee at all times Scenario: Buy last coffee Given there are 1 coffee left in the machine And I have deposited 1$ When I press the coffee button Then I should be served a coffee [Test] public void TestCoffeeMachine() { // Some test codes here }
  • 9. BDD Languages - Gherkin • Domain Specific Language • Easy to understand by customers • Simple with few keywords – Feature – Scenario, Scenario Outline – Given, When, Then • Localized to 35+ languages
  • 13. • Demo 1: Coffee Machine 13
  • 14. • Demo 2: Google Search (Compare with WatiN Hello World example) 14
  • 15. SpecFlow - Step Argument • Step definition: use regular expression to eliminate duplicate script 15
  • 16. SpecFlow - Table argument 16
  • 17. SpecFlow - Context 17 Data Sharing between steps/scenarios
  • 18. SpecFlow - Test Fixture • BeforeFeature/BeforeScenario: Precondition of each feature/scenario • AfterFeature/AfterScenario: Teardown or cleanup after test execution • Tags
  • 19. SpecFlow - Scenario Outline (Data Driven) Scenario: TC1 Add two numbers Given I have entered 1 into the calculator And I have entered 2 into the calculator When I press add Then the result should be 3 on the screen Scenario: TC2 Add two numbers Given I have entered 2 into the calculator And I have entered 2 into the calculator When I press add Then the result should be 4 on the screen
  • 20. Data driven on scenarios.
  • 21. From framework to platform • Test Report/Test Log 21 Nunit TestResults.txt TestResults.xml SpecificationResults.html SpecFlow • Test environment • Continuous build
  • 22. Patterns and Practices • Domain Driven Design • Singleton • Page object pattern • Driver pattern • Reusable modules 22
  • 23. Domain Driven Design • Express your tests in the language of the end-user of the app. 23  
  • 24. Web Browser in Singleton Mode public static class WebBrowser { public static IE Current { get { if (!ScenarioContext.Current.ContainsKey("browser")) ScenarioContext.Current["browser"] = new IE(); return ScenarioContext.Current["browser"] as IE; } } } 24
  • 25. Page Object Pattern • A simple abstraction of the UI of your web app. 25
  • 26. Driver Pattern • Driver object defines all actions/events among current page 26
  • 28. Summary • BDD Concept • SpecFlow Test Framework • Web Automation Practice 28 The framework and pattern matters, not the tools 
  • 29. Reference • Specification by Examples - http://specificationbyexample.com/ • MSDN article on BDD: http://msdn.microsoft.com/en- us/magazine/gg490346.aspx • BDD from NDC: http://vimeo.com/43536443 • WATIN and more: http://watinandmore.blogspot.com/ 29
  • 31. Thank you!  - 余宗宝(@Sandyshow) zbyu81@hotmail.com

Editor's Notes

  • #3: Thank you ChinaTest committee and all comings
  • #4: Thank you ChinaTest committee and all comings
  • #8: Why BDD?
  • #10: Together with demo to introduce in parallel
  • #19: Question: How to handle Login in your system?
  • #24: Express your tests in the language of the end-user of the our product/softwareBusiness level scenarios: To allow the creation of test scenarios ahead of the SUT delivery.Easy to maintain, less dependent on GUI changes.(domain-specific language, domain driven design....)Not functional point test: xxx dialog, xxx input box1. What must be automated?2. What should be automated?3. What could be automated?4. What won’t be automated?This method allowed us to focus our efforts on those test components that werenecessary and would give the greatest value by assessing the associated business risk,reusability, usage, complexity, and feasibility of each test component
  • #25: 1. In order to walk the browser through several steps in a scenario, you need a way to pass the same browser object between steps in the step definition class.Create a WebBrowser static class towork with the WatiN IE object and the ScenarioContext that SpecFlow uses to store state between steps in a scenario.2. Wrapper browsers/ EncapsulationIE/Firefox/Chrome3. WatiN/Selenium
  • #26: This is widely used in web automation, especially in Selenium community. Here I share my practicesThree essential parts of GUI automation: Find controls, Manipulate controls, VerifyPage object pattern: Find controls
  • #27: Manipulate controlsSeparate this from page object reason:Business logic is too complexSome module is reusable(example of section assessment page, section details page)
  • #28: Object model (user class)Loadable components (Documents tool/ selector tool /master page/logout link)ConstantsWatiN/SeleniumExtensionsWait
  • #29: Go through one real project framework
  • #31: Auto coverage?Easy to use?Selenium or WatiN?Dev/QA ratio?