Skip to content

Commit

Permalink
Document the assertion system
Browse files Browse the repository at this point in the history
  • Loading branch information
aaa2000 committed Oct 3, 2015
1 parent e7f9322 commit 6cc2186
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions guides/traversing-pages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,37 @@ that you can make same old traversing on such elements as well:
// find some field INSIDE form with class="register"
$field = $registerForm->findField('Email');
Webassert
~~~~~~~~~

The ``\Behat\Mink\WebAssert`` class provides a set of assertion. There are assertions
about the address of the page, the cookies, the status code, the response headers,
the content of the page, the page elements... An assertion can improve code readability
and avoid having a fatal error in method chaining.

For example, instead of:

.. code-block:: php
$registerForm = $page->find('css', 'form.register');
if (null === $registerForm) {
throw new \Exception('The element is not found');
}
// find some field INSIDE form with class="register"
$field = $registerForm->findField('Email');
you can do:

.. code-block:: php
field = $mink->assertSession()->fieldExists(
'Email',
// Throw exception when not found instead of returning null.
$mink->assertSession()->elementExists('css', 'form.register')
);
.. _selectors:

Expand Down

0 comments on commit 6cc2186

Please sign in to comment.