pear channel-discover [Link].
com
pear channel-discover [Link]
pear install behat/behat
Behat Cheat Sheet
by [Link] MIT Licence
Command line (behat)
--init
Behat
Behatinen
two
2 mots
words
Create the features directory
--config [Link]
--config=[Link]
Use config file
--format=html out=[Link]
Html Report
--expand
Display details
--story-syntax --lang=fr
--tags='@group1,@group2'
In French
Run tests on groups
Behat
Feature
en 2 mots
Feature: Descriptive text of what is desired
In order to realize a named business value
As an explicit system actor
I want to ...
Behat permet
automates
d'automatiser
the "acceptance
les tests testing"
d'acceptation
of the de
agile
la
mthodologie agile
methodology
"Scrum".
Scrum
Each
Les
testtests
is sont
written
rdigs
in dans
natural
une langue
naturelle
grce syntax.
la syntaxe Gherkin.
language
with
the Gherkin
Une
fonctionnalit
est dcrite
un fichier <nom-deA
feature
is described
by a dans
<[Link]>
file. A
[Link]>.
Une
fonctionnalit
regroupe un
feature
is a set of cases,
called
"Scenarios".
ensemble de cas, appels Scnarios.
Each scenario is defined by:
Scnario
-Chaque
Context
(Given) est dfini par:
un contexteevents
(Etant (When)
donn que)
- Triggering
- des
vnements
dclencheurs
(Quand)
An expected result (Then)
- un rsultat attendu (Alors)
Behat
Use examples
en 2 mots
Scenario Outline: Some determinable business situation
Scenario: Some determinable business situation
Given I have <initialAmount> euros
Given some precondition
When I add <money> euros
And some other precondition
Then I should have now <finalAmount> euros
When some action by the actor
And some other action
Examples:
And yet another action
Then some testable outcome is achieved
And something else we can check happens too
|
|
|
|
initialAmount
15
40
20
|
|
|
|
money
5
10
5
|
|
|
|
finalAmount
20
50
25
|
|
|
|
Scenario: A different situation
Web
Behatapps
en 2(Mink)
mots
Surf:
I am on "url"
Page 1 : fonctionnalits
Page 2 : ct dev
Assertions:
I should see "content"
I go to "url"
the response should contain "content"
I reload the page
I should not see "content"
I move backward one page
the response should not contain "content"
I move forward one page
the "form_element" field should contain "value"
I press "button"
the "form_element" field should not contain "value"
I follow "link"
the "form_checkbox" checkbox should be checked
Forms:
I fill in "form_element" with "value"
the "form_checkbox" checkbox should not be checked
I should be on "page"
I fill in "value" for "form_element"
the url should match "url"
I fill in the following
the "num_position" element should contain "value"
I select "form_option" from "form_select"
I should see "value" in the "element" element
I additionally select "form_option" from "form_select"
I should see an "element" element
I check "form_checkbox"
I should not see an "element" element
I uncheck "form_checkbox"
I should see number "element" elements
I attach the file "/path/[Link]" to "form_file"
the response status code should be code
Mink Cheat Sheet
by [Link] MIT Licence
Session
$session = new \Behat\Mink\Session($driver);
$session->start(); // start
$session->reset(); // soft-reset:
$session->restart(); // hard-reset:
From the main context:
$session = $this->getSession();
From a sub-context:
$session = $this->getMainContext()->getSession();
isStarted()
Checks whether session was
started
start()
Starts session
stop()
Stop session
restart()
Restart session
reset()
Reset session
getPage()
Returns page element
getSelectorHandler()
Returns Selector Handler
visit($url)
Visit specified URL
setBasicAuth($u,$p)
HTTP Basic authentification
setRequestHeader($n,$v)
Set request header
getResponseHeaders()
Get all response headers
setCookie($n,$v)
Sets cookie
getCookie($n)
Returns cookie
getStatusCode()
Returns response code
getCurrentUrl()
Returns current URL
reload()
Reload current page
back()
Moves backward
forward()
Move forward
executeScript($script)
Executes javascript
evaluateScript($script)
Returns javascript' response
wait($time, $condition)
Waits some time or until
javascript condition is true
Available drivers
Goutte:
[Link]
Sahi:
[Link]
Zombie:
[Link]
Selenium (1 & 2 ):
[Link]
pear channel-discover [Link]
pear channel-discover [Link]
pear install behat/mink-beta
Elements
$el->has($selector, $locator)
$el->find($selector, $locator)
$el->findAll($selector, $locator)
$el->getText()
$el->getHtml()
HTML nodes
$el->isVisible()
$el->getValue()
$el->getTagName()
$el->getXpath()
$el->hasAttribute($name)
$el->getAttribute($name)
Events:
$el->click()
$el->doubleClick()
$el->rightClick()
$el->mouseOver()
$el->focus()
$el->blur()
$el->dragTo($element)
Forms:
$el->press()
$el->check()
$el->uncheck()
$el->isChecked()
$el->selectOption($option, $multiple)
$el->attachFile($path)
$el->keypress()
$el->keyDown()
$el->keyUp()
Default parameters <[Link]>
default:
context:
parameters:
default_session: goutte
javascript_session: sahi
base_url:
[Link]
browser:
firefox
goutte:
zend_config:
adapter:
Zend\Http\Client\Adapter\Proxy
proxy_host:
[Link]
proxy_port:
8080
sahi:
host:
localhost
port:
9999
zombie:
host:
[Link]
port:
8124
node_bin:
node
auto_server: true
selenium:
host:
localhost
port:
4444
webdriver:
host
[Link]