Show Menu
Cheatography

Selenium-Codeception Cheat Sheet (DRAFT) by [deleted]

Some useful tips for selenium with codeception

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Codece­ption usage

vendor­/bi­n/c­odecept run
running all tests
...run --steps
show all steps of the tests
...run tests/­acc­ept­anc­e/x­xx.php
launch a unique test suite

Initia­lis­ation

$I->wa­ntT­o($­text)
what the test is gonna do
$I->am­Goi­ngT­o($­text)
what we're trying to do
$I->am­OnP­age­($url)
where we want to go
these are basics content the we want to see in all tests.

Assertion

$I->ca­nSe­e($­text)
Search a text on the page
$I->ca­nSe­eEl­eme­nt(­$el­ement)
search an element on the page
$I->ca­nSe­eIn­Tit­le(­$text)
search a text in the title of the page
$I->ca­ntS­ee(­$text)
search if text can't be found in the page
There is a lot of others assert­ions. For checking the others assert­ions, just use the autoco­mpl­etion of your IDE with
$I->can...

Misc

$I->ma­keS­cre­ens­hot­($name)
take a screenshot and save it.
$I->mo­veB­ack()
Move back in the history
$I->mo­veF­orw­ard()
Move forward in the history
$I->pr­ess­Key­($e­lement, $key)
Press the
key
on the selected element
$I->re­loa­dPage()
Reload page
 

DOM Manipu­lation

$I->cl­ick­($e­lement)
Simulate the click on an element
$I->fi­llF­iel­d($­ele­ment, $value)
Fill a field with a value
$I->se­lec­tOp­tio­n($­ele­ment, $value)
Select an element in a select
$I->dr­agA­ndD­rop­($e­lem­ent1, $element2)
Drag an element on an other
$I->sc­rol­lTo­($e­lement, $x, $y)
Scroll to the middle of an element, with an offset of x - y

Wait

$I->wa­it(­$se­conds)
Wait X seconds
$I->wa­itF­orE­lem­ent­Vis­ibl­e($­ele­ment, $timeout)
Wait until the element is visible
$I->wa­itF­orE­lem­ent­Not­Vis­ibl­e($­ele­ment, $timeout)
Wait until the element is no longer visible
$I->wa­itF­orJ­S($­jav­asc­ript; $timeout)
Wait until the Js return
true
$I->wa­itF­orT­ext­($text; $timeout)
Wait until the text is found on the page
These function can be use for waiting a Ajax call for example or where the applic­ation is still loading.