web automation in bdd
DESCRIPTION
Web UI automation test Specflow WatiN Page ObjectTRANSCRIPT
![Page 1: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/1.jpg)
Web Automation in BDD
SpecFlow + WatiN
![Page 2: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/2.jpg)
What about me?
2
![Page 3: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/3.jpg)
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
![Page 4: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/4.jpg)
Agenda
• BDD Introduction• Demo• BDD Test Framework (SpecFlow + WatiN)• Test design patterns/practices
4
![Page 5: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/5.jpg)
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
![Page 6: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/6.jpg)
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 }
![Page 7: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/7.jpg)
BDD vs TDD
![Page 8: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/8.jpg)
BDD Tools
![Page 9: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/9.jpg)
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
![Page 10: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/10.jpg)
Scenario: GIVEN, WHEN, THEN
10
![Page 11: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/11.jpg)
BDD Framework
11
![Page 12: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/12.jpg)
How SpecFlow Works?
Drives
GUI
![Page 13: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/13.jpg)
• Demo 1: Coffee Machine
13
![Page 14: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/14.jpg)
• Demo 2: Google Search (Compare with WatiN Hello World example)
14
![Page 15: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/15.jpg)
SpecFlow - Step Argument
• Step definition: use regular expression to eliminate duplicate script
15
![Page 16: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/16.jpg)
SpecFlow - Table argument
16
![Page 17: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/17.jpg)
SpecFlow - Context
17
Data Sharing between steps/scenarios
![Page 18: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/18.jpg)
SpecFlow - Test Fixture
• BeforeFeature/BeforeScenario: Precondition of each feature/scenario
• AfterFeature/AfterScenario: Teardown or cleanup after test execution
• Tags
![Page 19: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/19.jpg)
SpecFlow - Scenario Outline (Data Driven)
Scenario: TC1 Add two numbers
Given I have entered 1 into the calculatorAnd I have entered 2 into the calculatorWhen I press add
Then the result should be 3 on the screen
Scenario: TC2 Add two numbers
Given I have entered 2 into the calculatorAnd I have entered 2 into the calculatorWhen I press add
Then the result should be 4 on the screen
![Page 20: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/20.jpg)
Data driven on scenarios.
![Page 21: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/21.jpg)
From framework to platform
• Test Report/Test Log
21
NunitTestResults.txt
TestResults.xml
SpecificationResults.html
SpecFlow
• Test environment
• Continuous build
![Page 22: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/22.jpg)
Patterns and Practices
• Domain Driven Design• Singleton• Page object pattern• Driver pattern• Reusable modules
22
![Page 23: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/23.jpg)
Domain Driven Design
• Express your tests in the language of the end-user of the app.
23
![Page 24: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/24.jpg)
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 25: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/25.jpg)
Page Object Pattern
• A simple abstraction of the UI of your web app.
25
![Page 26: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/26.jpg)
Driver Pattern
• Driver object defines all actions/events among current page
26
![Page 27: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/27.jpg)
Reusable Modules
27
![Page 28: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/28.jpg)
Summary
• BDD Concept• SpecFlow Test Framework• Web Automation Practice
28
The framework and pattern matters, not the tools
![Page 29: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/29.jpg)
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
![Page 30: Web automation in BDD](https://reader038.vdocuments.us/reader038/viewer/2022103114/555126fab4c905325d8b467a/html5/thumbnails/30.jpg)
Questions?
Suggestions?