Skip to content

[Testing] Fixed the description of assertSelectorTextContains() #13514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,10 @@ Now you can use CSS selectors with the crawler. To assert that the phrase

$this->assertSelectorTextContains('html h1.title', 'Hello World');

This assertion will internally call ``$crawler->filter('html h1.title')``, which allows
you to use CSS selectors to filter any HTML element in the page and check for
its existence, attributes, text, etc.
This assertion checks if the first element matching the CSS selector contains
the given text. This asserts calls ``$crawler->filter('html h1.title')``
internally, which allows you to use CSS selectors to filter any HTML element in
the page and check for its existence, attributes, text, etc.

The ``assertSelectorTextContains`` method is not a native PHPUnit assertion and is
available thanks to the ``WebTestCase`` class.
Expand All @@ -223,15 +224,6 @@ available thanks to the ``WebTestCase`` class.

The ``WebTestCase`` assertions were introduced in Symfony 4.3

.. seealso::

Using native PHPUnit methods, the same assertion would look like this::

$this->assertGreaterThan(
0,
$crawler->filter('html h1.title:contains("Hello World")')->count()
);

The crawler can also be used to interact with the page. Click on a link by first
selecting it with the crawler using either an XPath expression or a CSS selector,
then use the client to click on it::
Expand Down