Skip to content

Commit b529188

Browse files
committed
Update the session doc thanks to @weaverryan's awesome review
1 parent 78519aa commit b529188

1 file changed

Lines changed: 27 additions & 25 deletions

File tree

guides/session.rst

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ Controlling the Browser
22
=======================
33

44
In Mink, the entry point to the browser is called the session. Think about
5-
it as being your browser window (some drivers even allow to deal with switching
6-
tabs).
5+
it as being your browser window (some drivers even let you switch tabs!).
76

8-
The first thing to do with your session is to start it. Nothing can be done
9-
with it before starting it.
7+
First, start your session (it's like opening your browser tab). Nothing can
8+
be done with it before starting it.
109

1110
.. code-block:: php
1211
@@ -26,17 +25,16 @@ with it before starting it.
2625

2726
.. caution::
2827

29-
Although Mink does its best on removing browser differences between different
30-
browser emulators, it can't do much in some cases. See the :ref:`driver-feature-support`
28+
Although Mink does its best to remove differences between the different
29+
drivers, each driver has unique features and shortcomings. See the :ref:`driver-feature-support`
3130
to see which features are supported by each driver.
3231

3332
Basic Browser Interaction
3433
-------------------------
3534

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.
35+
Now that your session is started, you'll want to open a page with it. Just
36+
after starting, the session is not on any page (in a real browser, you would
37+
on the ``about:blank`` page), and calling any other action is likely to fail.
4038

4139
.. code-block:: php
4240
@@ -45,8 +43,8 @@ to fail.
4543
.. note::
4644

4745
Mink is primarily designed to be used for testing websites. To allow
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
46+
you to browse and test error pages, the ``Session::visit`` method does
47+
not consider error status codes as invalid. It will not throw an exception
5048
in this case. You will need to check whether the response was a success
5149
or an error. It will only throw an exception when Mink cannot load the
5250
page (network error, ...). For cases, when driver does not support status
@@ -58,8 +56,9 @@ Interacting with the Page
5856

5957
The session gives you access to the page through the ``Session::getPage``
6058
method. This allows you to :doc:`traverse </guides/traversing-pages>` and
61-
:doc:`manipulate it </guides/manipulating-pages>`. The next chapters are
62-
covering the page API in depth.
59+
:doc:`manipulate it </guides/manipulating-pages>`. The next chapters cover
60+
the page API in depth. Most of what you'll do with Mink will use this object,
61+
but you can continue reading to learn more about the Session.
6362

6463
Using the Browser History
6564
-------------------------
@@ -76,8 +75,8 @@ The session gives you access to the browser history:
7675
$session->back();
7776
$session->forward();
7877
79-
Cookies Management
80-
------------------
78+
Cookie Management
79+
-----------------
8180

8281
The session can manipulate cookies available in the browser.
8382

@@ -94,8 +93,9 @@ The session can manipulate cookies available in the browser.
9493
9594
.. note::
9695

97-
In browser controllers, you may be be restricted to controlling only
98-
http-only cookies because others cannot be accessed through JavaScript.
96+
With drivers that use a browser - like Selenium2 - you may be restricted
97+
to accessing/setting only `HttpOnly cookies`_ because others cannot be
98+
accessed through JavaScript.
9999

100100
Status Code Retrieval
101101
---------------------
@@ -122,8 +122,8 @@ The session lets you manipulate request headers and access response headers:
122122
123123
.. note::
124124

125-
Headers handling is only supported in headless drivers, because there
126-
is no way browser controllers can get such information out of the browser.
125+
Headers handling is only supported in headless drivers (e.g. Goutte).
126+
Browser controllers (e.g. Selenium2) cannot access that information.
127127

128128
HTTP Authentication
129129
-------------------
@@ -190,8 +190,8 @@ Resetting the Session
190190
The primary aim for Mink is to provide a single consistent web browsing API
191191
for acceptance tests. But a very important part in testing is isolation.
192192

193-
Mink provides two very useful methods to isolate tests, to be used in your
194-
test ``teardown`` methods:
193+
Mink provides two very useful methods to isolate tests, which can be used
194+
in your test's ``teardown`` methods:
195195

196196
.. code-block:: php
197197
@@ -204,9 +204,9 @@ test ``teardown`` methods:
204204
$session->restart();
205205
206206
Stopping the session is the best way to reset the session to its initial
207-
state. It will close the browser entirely. Using the session again requires
208-
starting the session before any other action. The ``Session::restart`` shortcut
209-
allows to do these 2 steps in a single actions.
207+
state. It will close the browser entirely. To use the session again, you
208+
need to start the session before any other action. The ``Session::restart``
209+
shortcut allows you to do these 2 steps in a single call.
210210

211211
The drawback of closing the browser and starting it again is that it takes
212212
time. In many cases, a lower level of isolation is enough in favor of a faster
@@ -216,3 +216,5 @@ to the limit of the driver possibilities.
216216

217217
Taking all this into account, it is recommended to use ``Session::reset()``
218218
by default and to call ``Session::stop()`` when you need really full isolation.
219+
220+
.. _HttpOnly cookies: http://en.wikipedia.org/wiki/HTTP_cookie#HttpOnly_cookie

0 commit comments

Comments
 (0)