Skip to content

zsim0n/MinkJavascriptExample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mink Javascript Example

This is a working example from David Winter's article with additional explanation and updated example.

Usage

Clone this repo:

git clone https://github.com/mopad/MinkJavascriptExample

Now install Behat, Mink, MinkExtension, PHPUnit and their dependencies with composer:

curl http://getcomposer.org/installer | php
php composer.phar install

Selenium

You'll need to install Selenium to test the @javascript feature. Selenium gives you ability to run @javascript tagged scenarios in real browser.

  1. Download latest Selenium jar from the Selenium website

  2. Download additional web drivers if necessary

  3. Run selenium jar with:

    java -jar selenium-server.jar

    Note: you can use the following additional arguments to setup the selenium-server

     - -Dwebdriver.ie.driver=IEDriverServer.exe
     - -Dwebdriver.chrome.driver=chromedriver.exe
     - -Dwebdriver.firefox.bin=firefox.exe
    

Run tests

To launch Behat, just run:

vendor/bin/behat

You should see an output like:

Feature: Javascript support in Behat/Mink
    In order to test Javascript on a website
    As a Tester
    I can write Behat Scenarions with Javascript support
    So I can test javascript behaviour on a website

  Scenario: Open a page                         # features\twitter.bootstrap.feature:7
    Given I am on "/javascript.html"            # FeatureContext::visit()
    Then I should see "JavaScript in Bootstrap" # FeatureContext::assertPageContainsText()

  @javascript
  Scenario: Open modal dialog                   # features\twitter.bootstrap.feature:12
    Given I am on "/javascript.html#modal"      # FeatureContext::visit()
    And I should see "Live demo"                # FeatureContext::assertPageContainsText()
    When I follow "Launch demo modal"           # FeatureContext::clickLink()
    Then I should see the modal "Modal Heading" # FeatureContext::iShouldSeeTheModal()
    And I should see "Text in a modal"          # FeatureContext::assertPageContainsText()

2 scenarios (2 passed)
7 steps (7 passed)
0m8.675s

About

Article http://davidwinter.me/articles/2012/01/14/testing-javascript-websites-with-behat/ explained. Extended composer.json Example updated. Related repository: https://github.com/davidwinter/Testing-Javascript-websites-with-Behat

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages