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
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
PPTX
AQUEEL MUSHTAQUE FAKIH COMPUTER CENTER .
PDF
NewMind AI Journal Monthly Chronicles - August 2025
PDF
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
PDF
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
PDF
Examining Bias in AI Generated News Content.pdf
PDF
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
PDF
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
PDF
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
PDF
CEH Module 2 Footprinting CEH V13, concepts
PDF
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
PDF
Decision Optimization - From Theory to Practice
PDF
Introduction to MCP and A2A Protocols: Enabling Agent Communication
PDF
A symptom-driven medical diagnosis support model based on machine learning te...
PDF
The AI Revolution in Customer Service - 2025
PDF
Early detection and classification of bone marrow changes in lumbar vertebrae...
PDF
Identification of potential depression in social media posts
PDF
EIS-Webinar-Regulated-Industries-2025-08.pdf
PDF
Lung cancer patients survival prediction using outlier detection and optimize...
PPTX
How to use fields_get method in Odoo 18
zbrain.ai-Scope Key Metrics Configuration and Best Practices.pdf
AQUEEL MUSHTAQUE FAKIH COMPUTER CENTER .
NewMind AI Journal Monthly Chronicles - August 2025
ment.tech-Siri Delay Opens AI Startup Opportunity in 2025.pdf
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
Examining Bias in AI Generated News Content.pdf
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
CEH Module 2 Footprinting CEH V13, concepts
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
Decision Optimization - From Theory to Practice
Introduction to MCP and A2A Protocols: Enabling Agent Communication
A symptom-driven medical diagnosis support model based on machine learning te...
The AI Revolution in Customer Service - 2025
Early detection and classification of bone marrow changes in lumbar vertebrae...
Identification of potential depression in social media posts
EIS-Webinar-Regulated-Industries-2025-08.pdf
Lung cancer patients survival prediction using outlier detection and optimize...
How to use fields_get method in Odoo 18

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) [email protected]

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?