• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
ATDD with Behat and Selenium (LDNSE6)
 

ATDD with Behat and Selenium (LDNSE6)

on

  • 4,172 views

These are the slides of the talk given at London Selenium Meetup on 29 may 2012. This talk was on Behat, MinkExtension and Selenium. http://www.meetup.com/seleniumlondon/events/61732192/ ...

These are the slides of the talk given at London Selenium Meetup on 29 may 2012. This talk was on Behat, MinkExtension and Selenium. http://www.meetup.com/seleniumlondon/events/61732192/
Pic : http://www.meetup.com/seleniumlondon/photos/8638912/#124419342

Statistics

Views

Total Views
4,172
Views on SlideShare
3,919
Embed Views
253

Actions

Likes
6
Downloads
38
Comments
0

6 Embeds 253

http://shashikantjagtap.net 225
http://www.sfexception.com 23
http://www.linkedin.com 2
http://diysdk.schlund.de 1
https://si0.twimg.com 1
http://localhost 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    ATDD with Behat and Selenium (LDNSE6) ATDD with Behat and Selenium (LDNSE6) Presentation Transcript

    • ATDD with Behat and Selenium
    • About MeShashikant Jagtap [Shashi]Twitter: @Shashikant86London Behat Users [#LDNBU]BDD Enthusiastic Tester
    • OverviewATDD
    • OverviewATDDBehat from Scratch
    • OverviewATDDBehat from ScratchComposer & Mink Extension
    • OverviewATDDBehat from ScratchComposer & MinkExtensionSpeeding up BDD with Sublime Text2Browser Automation with SeleniumATDD with Behat and SeleniumANT & HTML Report GenerationVideo/Live Demo
    • ATDDAcceptance Test Driven Development Discuss Stor Stor y2 Stor y3 y1
    • ATDDAcceptance Test Driven Development Specification Workshop Discuss Distill Stor Stor y2 Stor y3 Tester Develope y1 PM/S rs M
    • ATDDAcceptance Test Driven Development Specification Workshop Discuss Distill Stor Stor y2 Stor y3 Tester PM/S Develope y1 M rs Acceptance Tests Implement Test Devel er oper
    • ATDD Acceptance Test Driven Development Specification Workshop Discuss Distill Stor Stor y2 Stor y3 Tester PM/S Develope y1 M rs Acceptance Tests Executable Spec ImplementAutomat Demo ion Test Automat Devel er ion oper
    • ATDDGet Acceptance Criteria
    • ATDDGet Acceptance CriteriaWrite Acceptance Test Collaboratively [Failing/Undefined]
    • ATDDGet Acceptance CriteriaWrite Acceptance Test Collaboratively [Failing/Undefined]Implement Step Definition to make it Pass
    • ATDDGet Acceptance CriteriaWrite Acceptance Test Collaboratively [Failing/Undefined]Implement Step Definition to make it PassTest Pass !! Automation Achieved.
    • BehatIts cousin of
    • BehatBehat is a BDD tool for PHP Applications http://behat.org/Mink is a web Acceptance Testing Framework for PHP http://mink.behat.org/Combination of Behat/Mink can be used for web acceptance Testing.Mink has Selenium1 & Selenium2 Drivers for browser automation
    • Who is Doing/Maintaining?Konstantin Kudryashov - Knplabs, FranceTwitter : @everzetGitHub : Everzet+ Some Awesome Contributors
    • Lets Get Started With Behat Pre-requisiteLaptop/ComputerPHP Stacks (LAMP, WAMP, MAMP)Selenium ServerCurl or wgetGitHub (optional)
    • Behat Installation
    • Could you Live Without
    • If Not Then
    • If Not Then$ pear channel-discover pear.symfony.com$ pear channel-discover pear.behat.org$ pear install behat/behatpear install behat/mink
    • If Not Then$ pear channel-discover pear.symfony.com$ pear channel-discover pear.behat.org$ pear install behat/behatpear install behat/minkYou Ready to use Behat/Mink,
    • If Not Then$ pear channel-discover pear.symfony.com$ pear channel-discover pear.behat.org$ pear install behat/behatpear install behat/minkYou Ready to use Behat/Mink,WAIT.... We got EASIER OPTION !!!!!
    • We Got Composer !!!!!!
    • We Got Composer !!!!!!Composer is dependency manager for PHPComposer allow you to declare libraries you needed and install it for youJust define all dependencies in composer.json file and you are done !!So, Lets do that
    • Create Project Make New Directory$ mkdir BehatDemo$ cd BehatDemo
    • Create composer.json{"require": { "behat/behat": "2.4@stable", "behat/mink-extension": "dev-master", "fabpot/goutte": "*", "alexandresalome/php-selenium": "*", "instaclick/php-webdriver": "*" }, "config": { "bin-dir": "bin" }}
    • Create behat.ymldefault:context: class: FeatureContext extensions: BehatMinkExtensionExtension: base_url: http://saucelabs.com/ javascript_session: selenium2 goutte: ~ selenium2:
    • Download ComposerDownload composer using command$curl http://getcomposer.org/installer | php
    • Download ComposerDownload composer using command$curl http://getcomposer.org/installer | phpShashi-MacBook-Pro:BehatDemo user$ curl http://getcomposer.org/installer | php % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 7606 100 7606 0 0 59636 0 --:--:-- --:--:-- --:--:-- 165k#!/usr/bin/env phpAll settings correct for using ComposerDownloading...Composer successfully installed to: /Users/user/BehatDemo/composer.pharUse it: php composer.phar
    • Install composer.phar$php composer.phar installYou can also use$php composer.phar update
    • Install composer.phar$php composer.phar installShashi-MacBook-Pro:BehatDemo user$ php composer.phar updateUpdating dependencies- Installing guzzle/guzzle (v2.6.3) Downloading: 100%- Installing symfony/yaml (dev-master) Cloning 49ad500448c17a4b515c8f567dbb540af3cf41ef- Installing symfony/translation (dev-master) [So on …...........]
    • Start Behat$ ./bin/behat --init
    • Start Behat$ ./bin/behat --initShashi-MacBook-Pro:BehatDemo user$ ./bin/behat --init+d features - place your *.feature files here+d features/bootstrap - place bootstrap scripts and static files here+f features/bootstrap/FeatureContext.php - place your feature related code here[You will See Behat created features and bootstrap directory for you]
    • Behat Did Something ?Created features directoryCreated bootstrap directory and FeatureContext.php file where we will implement step definitions.
    • Mink ExtensionWe need FeatureContext class toBehat MinkExtensionContextMinkContextSo, We are using MinkExtension which automatically create Mink instance.We used Mink APIs to automated Browser actions. (http://mink.behat.org/api/)
    • Now, We are ready to use Behat, Mink, Selenium and stuff. Run Behat with $ ./bin/behat
    • Feature File
    • How it Looks Like?Feature: featureIn order to [ add feature]As a [role]I want [featute]Scenario: First ScenarioGiven [Context]When [Action]Then [OutCome]
    • BlogSearch.featureFeature: Blog SearchIn order to search blogsAs a sauce userI need see blogs@javascriptScenario: Search Behat BlogsGiven I am on "/blog"When I fill in "s" with "behat"And I press "Search"Then I should see "Adding Sauce To Behat"[This file should be in /features directory. ]
    • What will Help to write feature?Behat Cheat Sheethttp://blog.lepine.pro/php/ressources-tutos-Mink Apishttp://mink.behat.org/api/
    • I know, Too Boring to type ?
    • I know, Too Boring to type ?Let Me Show You Something Which Will do this in a Minute
    • Sublime Text2 : Behat- Mink Snippets.
    • Who Wrote Awesome SnippetsWillemsen ChristopheGitHub : kwattro- Intranet appz developer for the Belgian Defense, BDD practitioner. [ Symfony]Twitter : @ikwattroGitHub: https://github.com/kwattro/sublime- behat-snippets
    • Dont forgetTo tag Scenarios with “@javascript” tag &Launch our Lovely Selenium Server$ java -jar selenium-server-standalone-2.21.0.jar
    • Now Run $./bin/behatWatch Test Running in a Browser
    • ATDD with Behat & SeleniumHow should I find locators before Implementation?
    • ATDD with Behat & SeleniumHow should I find locators before Implementation?Dont worry, Write high level tests and Behat & Mink APIs will help you to implement Step def later (after implementation)
    • atdd.featureFeature: ATDDIn order to implement ATDDAs a QAI need to write acceptance tests first @javascript @atdd Scenario: Searching Given I am on blogs page When I search for "chips" Then I should see "No Posts"
    • Implement Steps/** * @When /^I search for "([^"]*)"$/ */    public function iSearchFor($key) {   $this->fillField("s", $key);        $this->pressButton("Search"); }    /** * @Given /^I am on blogs page$/ */    public function iAmOnBlogsPage()    {        $this->visit("/blog");    }
    • Run Scenarios with atdd tags$ ./bin/behat --tags="atdd"
    • Generate ReportTo Generate HTML reports$ ./bin/behat -f html --out report.htmlYou will see report.html generated which looks awesome in browser !!
    • report.html
    • Get Code$git clone git@github.com:Shashikant86/BehatDemo.git$cd BehatDemo$curl http://getcomposer.org/installer | php$php composer.phar installDownload Selenium Server and launch server$ java -jar selenium-server-standalone-2.21.0.jar$./bin/behat
    • Run ANT buildShashi-MacBook-Pro:BehatDemo user$ ant runBuildfile: /Users/user/BehatDemo/build.xmlrun: [delete] Deleting directory /Users/user/BehatDemo/report [mkdir] Created dir: /Users/user/BehatDemo/reportbehat:BUILD SUCCESSFUL
    • ReportsWe have created report directory to save test report of the latest buildReport will generate in html format in the report/report.html file.
    • Video DemoHow To clone Repo and usehttp://youtu.be/Apt-1_94zCEThings We didhttp://tinyurl.com/d79s4oy
    • Linkshttp://behat.org/http://mink.behat.org/https://github.com/Shashikant86/BehatDemohttps://github.com/kwattro/sublime-behat-snippetshttp://everzet.com/
    • Questions?
    • Thank You