Skip to content

Commit 78519aa

Browse files
committed
Update the session doc based on the review
1 parent 296d697 commit 78519aa

1 file changed

Lines changed: 28 additions & 27 deletions

File tree

guides/session.rst

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ with it before starting it.
1010

1111
.. code-block:: php
1212
13-
// choose a Mink driver. More about it in later chapters
13+
// Choose a Mink driver. More about it in later chapters.
1414
$driver = new \Behat\Mink\Driver\GoutteDriver();
1515
1616
$session = new \Behat\Mink\Session($driver);
@@ -20,12 +20,11 @@ with it before starting it.
2020
2121
.. note::
2222

23-
The first argument to the session constructor is a driver object, which
24-
is how the Mink abstraction layer works. You will discover more about
25-
the available drivers in a :doc:`later chapter </guides/drivers>`.
23+
The first argument to the session constructor is a driver object. Drivers
24+
are the way the Mink abstraction layer works. You will discover more
25+
about the available drivers in a :doc:`later chapter </guides/drivers>`.
2626

27-
28-
.. note::
27+
.. caution::
2928

3029
Although Mink does its best on removing browser differences between different
3130
browser emulators, it can't do much in some cases. See the :ref:`driver-feature-support`
@@ -34,9 +33,10 @@ with it before starting it.
3433
Basic Browser Interaction
3534
-------------------------
3635

37-
The first thing to do to use your session is to open a page with it. Just
38-
after starting, the session is not on any page (in a real browser, you would
39-
on ``about:blank``), and calling any other action is likely to fail.
36+
The first thing to do when using your session is to open a page with it.
37+
Just after starting, the session is not on any page (in a real browser, you
38+
would on the ``about:blank`` page), and calling any other action is likely
39+
to fail.
4040

4141
.. code-block:: php
4242
@@ -45,17 +45,19 @@ on ``about:blank``), and calling any other action is likely to fail.
4545
.. note::
4646

4747
Mink is primarily designed to be used for testing websites. To allow
48-
covering error pages as well, ``Session::visit`` does not consider that
49-
error status codes are invalid. It will not throw an exception in this
50-
case. You will need to check whether the response was a success or an
51-
error. It will only throw an exception when Mink cannot load the page
52-
(network error, ...).
48+
covering error pages as well, the ``Session::visit`` method does not
49+
consider error status codes as invalid. It will not throw an exception
50+
in this case. You will need to check whether the response was a success
51+
or an error. It will only throw an exception when Mink cannot load the
52+
page (network error, ...). For cases, when driver does not support status
53+
code retrieval, it might be possible to assert text on the page itself
54+
to determine whether it is an error page or no.
5355

5456
Interacting with the Page
5557
-------------------------
5658

5759
The session gives you access to the page through the ``Session::getPage``
58-
method. This allows you to :doc:`traverse it </guides/traversing-pages>` and
60+
method. This allows you to :doc:`traverse </guides/traversing-pages>` and
5961
:doc:`manipulate it </guides/manipulating-pages>`. The next chapters are
6062
covering the page API in depth.
6163

@@ -92,8 +94,8 @@ The session can manipulate cookies available in the browser.
9294
9395
.. note::
9496

95-
In browser controllers, the access to http-only cookies may be restricted
96-
as they cannot be accessed in Javascript.
97+
In browser controllers, you may be be restricted to controlling only
98+
http-only cookies because others cannot be accessed through JavaScript.
9799

98100
Status Code Retrieval
99101
---------------------
@@ -126,7 +128,7 @@ The session lets you manipulate request headers and access response headers:
126128
HTTP Authentication
127129
-------------------
128130

129-
The Mink session has a special method to perform HTTP Basic authentication:
131+
The session has a special method to perform HTTP Basic authentication:
130132

131133
.. code-block:: php
132134
@@ -152,7 +154,7 @@ The session allows you to execute or evaluate Javascript.
152154
.. code-block:: php
153155
154156
// Execute JS
155-
$session->evaluateScript('document.body.firstChild.innerHtml = "";');
157+
$session->executeScript('document.body.firstChild.innerHtml = "";');
156158
157159
// evaluate JS expression:
158160
echo $session->evaluateScript(
@@ -165,22 +167,22 @@ The session allows you to execute or evaluate Javascript.
165167
returns the result of the expression. When you don't need to get a return
166168
value, using ``Session::executeScript`` is better.
167169

168-
You can also wait until a give JS expression returns a truthy value or the
170+
You can also wait until a given JS expression returns a truthy value or the
169171
timeout is reached:
170172

171173
.. code-block:: php
172174
173175
// wait for n milliseconds or
174-
// till JS expression becomes true:
176+
// till JS expression becomes truthy:
175177
$session->wait(
176178
5000,
177179
"$('.suggestions-results').children().length"
178180
);
179181
180182
.. note::
181183

182-
The ``Session::wait`` method returns the result of the evaluation. It
183-
will return ``null`` when the timeout is reached.
184+
The ``Session::wait`` method returns ``true`` when the evaluation becomes
185+
truthy. It will return ``false`` when the timeout is reached.
184186

185187
Resetting the Session
186188
---------------------
@@ -189,7 +191,7 @@ The primary aim for Mink is to provide a single consistent web browsing API
189191
for acceptance tests. But a very important part in testing is isolation.
190192

191193
Mink provides two very useful methods to isolate tests, to be used in your
192-
``teardown`` methods:
194+
test ``teardown`` methods:
193195

194196
.. code-block:: php
195197
@@ -210,8 +212,7 @@ The drawback of closing the browser and starting it again is that it takes
210212
time. In many cases, a lower level of isolation is enough in favor of a faster
211213
resetting. The ``Session::reset`` method covers this use case. It will try
212214
to clear the cookies and reset the request headers and the browser history
213-
in the limit of the driver possibilities.
215+
to the limit of the driver possibilities.
214216

215217
Taking all this into account, it is recommended to use ``Session::reset()``
216-
by default and to call ``Session::stop()`` in cases when we need really full
217-
isolation.
218+
by default and to call ``Session::stop()`` when you need really full isolation.

0 commit comments

Comments
 (0)