Skip to content

Commit 9882acb

Browse files
committed
Update the "traversing pages" chapter based on the review
1 parent d2704d5 commit 9882acb

1 file changed

Lines changed: 30 additions & 28 deletions

File tree

guides/traversing-pages.rst

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ inside the current element while ``ElementInterface::find`` returns the first
3737
match or ``null`` when there is none.
3838

3939
The ``TraversableElement`` class also provides a bunch of shortcut methods
40-
on top of ``find()`` to make it easier to achieve many common use case:
40+
on top of ``find()`` to make it easier to achieve many common use cases:
4141

4242
``ElementInterface::has``
4343
Checks whether a child element matches the given selector but without
@@ -68,7 +68,7 @@ Nested Traversing
6868

6969
Every ``find*()`` method will return a ``Behat\Mink\Element\NodeElement`` instance
7070
and ``findAll()`` will return an array of such instances. The fun part is
71-
you can make same old traversing on such elements too:
71+
that you can make same old traversing on such elements as well:
7272

7373
.. code-block:: php
7474
@@ -92,36 +92,38 @@ support several kinds of selectors to find elements.
9292
CSS Selector
9393
~~~~~~~~~~~~
9494

95-
The ``css`` selector type lets you use CSS expressions to search elements
96-
in the page:
95+
The ``css`` selector type lets you use CSS expressions to search for elements
96+
on the page:
9797

9898
.. code-block:: php
9999
100100
$title = $page->find('css', 'h1');
101101
102+
$buttonIcon = $page->find('css', '.btn > .icon');
103+
102104
XPath Selector
103105
~~~~~~~~~~~~~~
104106

105-
The ``xpath`` selector type lets you use XPath queries to search elements
106-
in the page:
107+
The ``xpath`` selector type lets you use XPath queries to search for elements
108+
on the page:
107109

108110
.. code-block:: php
109111
110112
$anchorsWithoutUrl = $page->findAll('xpath', '//a[not(@href)]');
111113
112114
.. caution::
113115

114-
This selector searches an element inside the current node (which is ``<html>``
115-
for the page object). This means that trying to pass it the XPath of
116-
and element retrieved with ``ElementInterface::getXpath`` will not work
117-
(this query includes the query for the root node). To check whether an
118-
element object still exists in the browser page, use ``ElementInterface::isValid``
116+
This selector searches for an element inside the current node (which
117+
is ``<html>`` for the page object). This means that trying to pass it
118+
the XPath of and element retrieved with ``ElementInterface::getXpath``
119+
will not work (this query includes the query for the root node). To check
120+
whether an element object still exists on the browser page, use ``ElementInterface::isValid``
119121
instead.
120122

121123
.. _named-selector:
122124

123-
Named Selector
124-
~~~~~~~~~~~~~~
125+
Named Selectors
126+
~~~~~~~~~~~~~~~
125127

126128
Named selectors provide a set of reusable queries for common needs. For conditions
127129
based on the content of elements, the named selector will try to find an
@@ -148,40 +150,40 @@ search with this query:
148150
The following queries are supported by the named selector:
149151

150152
``id``
151-
Searches an element by its id.
153+
Searches for an element by its id.
152154
``id_or_name``
153-
Searches an element by its id or name.
155+
Searches for an element by its id or name.
154156
``link``
155-
Searches a link by its id, title, img alt, rel or text.
157+
Searches for a link by its id, title, img alt, rel or text.
156158
``button``
157-
Searches a button by its name, id, text, img alt or title.
159+
Searches for a button by its name, id, text, img alt or title.
158160
``link_or_button``
159161
Searches for both links and buttons.
160162
``content``
161-
Searches a specific page content (text).
163+
Searches for a specific page content (text).
162164
``field``
163-
Searches a form field by its id, name, label or placeholder.
165+
Searches for a form field by its id, name, label or placeholder.
164166
``select``
165-
Searches a select field by its id, name or label.
167+
Searches for a select field by its id, name or label.
166168
``checkbox``
167-
Searches a checkbox by its id, name, or label.
169+
Searches for a checkbox by its id, name, or label.
168170
``radio``
169-
Searches a radio button by its id, name, or label.
171+
Searches for a radio button by its id, name, or label.
170172
``file``
171-
Searches a file input by its id, name, or label.
173+
Searches for a file input by its id, name, or label.
172174
``optgroup``
173-
Searches an optgroup by its label.
175+
Searches for an optgroup by its label.
174176
``option``
175-
Searches an option by its content or value.
177+
Searches for an option by its content or value.
176178
``fieldset``
177-
Searches a fieldset by its id or legend.
179+
Searches for a fieldset by its id or legend.
178180
``table``
179-
Searches a table by its id or caption.
181+
Searches for a table by its id or caption.
180182

181183
Custom Selector
182184
~~~~~~~~~~~~~~~
183185

184-
Mink lets you register your own selector types by implement the ``Behat\Mink\Selector\SelectorInterface``.
186+
Mink lets you register your own selector types through implementing the ``Behat\Mink\Selector\SelectorInterface``.
185187
It should then be registered in the ``SelectorsHandler`` which is the registry
186188
of available selectors.
187189

0 commit comments

Comments
 (0)