Sunteți pe pagina 1din 2

pear channel-discover pear.symfony.

com
Behat Cheat Sheet
pear channel-discover pear.behat.org
pear install behat/behat
by blog.lepine.pro MIT Licence

Command line (behat) Behat


Behatinen
two
2 mots
words

--init Create the features directory Behat permet


automates
d'automatiser
the "acceptance
les tests testing"
d'acceptation
of the de
agile
la
--config fichier.yml
--config=fichier.yml mthodologie agile
methodology "Scrum".
Scrum
Each Les
testtests
is sont
written
rdigs
in dans
natural
Use config file
une langue
language with the Gherkin
naturelle grce syntax.
la syntaxe Gherkin.
--format=html out=report.html Html Report
--expand Display details Une
A fonctionnalit
feature est dcrite
is described by a dans un fichier <nom-de-
<my-feature.feature> file. A
--story-syntax --lang=fr fonctionnalit.feature>.
feature Une
is a set of cases, fonctionnalit
called regroupe un
"Scenarios".
In French
ensemble de cas, appels Scnarios.
--tags='@group1,@group2' Run tests on groups Each scenario is defined by:
-Chaque
ContextScnario
(Given) est dfini par:
Behat
Feature
en 2 mots un contexteevents
(Etant (When)
donn que)
- Triggering
Feature: Descriptive text of what is desired - des vnements dclencheurs
An expected result (Then) (Quand)
In order to realize a named business value - un rsultat attendu (Alors)
As an explicit system actor
Behat
Use examples
en 2 mots
I want to ...
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 | initialAmount | money | finalAmount |
Then some testable outcome is achieved | 15 | 5 | 20 |
And something else we can check happens too | 40 | 10 | 50 |
| 20 | 5 | 25 |
Scenario: A different situation

Web
Behatapps
en 2(Mink)
mots
Surf: Assertions:
I should see "content"
I am on "url"
Page 1 : fonctionnalits
I go to "url" the response should contain "content"
Page 2 : ct dev I should not see "content"
I reload the page
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
the "form_checkbox" checkbox should not be checked
Forms:
I fill in "form_element" with "value" 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/file.file" to "form_file" the response status code should be code
pear channel-discover pear.symfony.com
Mink Cheat Sheet
pear channel-discover pear.behat.org
pear install behat/mink-beta
by blog.lepine.pro MIT Licence

Session Elements

$session = new \Behat\Mink\Session($driver); $el->has($selector, $locator)


$session->start(); // start $el->find($selector, $locator)
$session->reset(); // soft-reset: $el->findAll($selector, $locator)
$session->restart(); // hard-reset: $el->getText()
From the main context: $el->getHtml()
$session = $this->getSession();
HTML nodes
From a sub-context:
$session = $this->getMainContext()->getSession(); $el->isVisible() Events:
$el->getValue() $el->click()
isStarted() Checks whether session was $el->doubleClick()
$el->getTagName()
started
$el->getXpath() $el->rightClick()
start() Starts session $el->mouseOver()
$el->hasAttribute($name)
stop() Stop session $el->focus()
$el->getAttribute($name)
restart() Restart session $el->blur()
Forms:
reset() Reset session $el->press() $el->dragTo($element)
getPage() Returns page element $el->check()
getSelectorHandler() Returns Selector Handler $el->uncheck()
visit($url) Visit specified URL $el->isChecked()
$el->selectOption($option, $multiple)
setBasicAuth($u,$p) HTTP Basic authentification
$el->attachFile($path)
setRequestHeader($n,$v) Set request header
$el->keypress()
getResponseHeaders() Get all response headers $el->keyDown()
setCookie($n,$v) Sets cookie $el->keyUp()
getCookie($n) Returns cookie
Default parameters <behat.yml>
getStatusCode() Returns response code
getCurrentUrl() Returns current URL default:
context:
reload() Reload current page parameters:
back() Moves backward default_session: goutte
javascript_session: sahi
forward() Move forward base_url: http://localhost
browser: firefox
executeScript($script) Executes javascript
goutte:
evaluateScript($script) Returns javascript' response zend_config:
adapter:
wait($time, $condition) Waits some time or until
Zend\Http\Client\Adapter\Proxy
javascript condition is true proxy_host: host.com
proxy_port: 8080
sahi:
Available drivers host: localhost
port: 9999
Goutte: zombie:
https://github.com/fabpot/Goutte host: 127.0.0.1
Sahi: port: 8124
node_bin: node
http://sourceforge.net/projects/sahi/ auto_server: true
Zombie: selenium:
http://zombie.labnotes.org/ host: localhost
port: 4444
Selenium (1 & 2 ): webdriver:
http://seleniumhq.org/ host http://localhost:4444/wd/hub

S-ar putea să vă placă și