Skip to content

Commit 726d8f4

Browse files
committed
minor #20564 [Panther] Sync documentation from upstream (alexandre-daubois)
This PR was merged into the 6.4 branch. Discussion ---------- [Panther] Sync documentation from upstream After symfony/panther#617 (comment), cc `@OskarStark` Commits ------- efb59e6 [Panther] Sync documentation from upstream
2 parents 663ad9a + efb59e6 commit 726d8f4

File tree

2 files changed

+58
-11
lines changed

2 files changed

+58
-11
lines changed

.doctor-rst.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,4 @@ whitelist:
117117
- '.. versionadded:: 3.0' # Doctrine ORM
118118
- '.. _`a feature to test applications using Mercure`: https://github.com/symfony/panther#creating-isolated-browsers-to-test-apps-using-mercure-or-websocket'
119119
- 'End to End Tests (E2E)'
120+
- '.. versionadded:: 2.2.0' # Panther

testing/end_to_end.rst

+57-11
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ Here is an example of a snippet that uses Panther to test an application::
111111
$client->clickLink('Getting started');
112112

113113
// wait for an element to be present in the DOM, even if hidden
114-
$crawler = $client->waitFor('#installing-the-framework');
114+
$crawler = $client->waitFor('#bootstrapping-the-core-library');
115115
// you can also wait for an element to be visible
116-
$crawler = $client->waitForVisibility('#installing-the-framework');
116+
$crawler = $client->waitForVisibility('#bootstrapping-the-core-library');
117117

118118
// get the text of an element thanks to the query selector syntax
119-
echo $crawler->filter('#installing-the-framework')->text();
119+
echo $crawler->filter('div:has(> #bootstrapping-the-core-library)')->text();
120120
// take a screenshot of the current page
121121
$client->takeScreenshot('screen.png');
122122

@@ -305,13 +305,13 @@ faster. Two alternative clients are available:
305305
* The second leverages :class:`Symfony\\Component\\BrowserKit\\HttpBrowser`.
306306
It is an intermediate between Symfony's kernel and Panther's test clients.
307307
``HttpBrowser`` sends real HTTP requests using the
308-
:doc:`HttpClient component </http_client>`. It is fast and is able to browse
308+
:doc:`HttpClient component </http_client>`. It is fast and can browse
309309
any webpage, not only the ones of the application under test.
310310
However, HttpBrowser doesn't support JavaScript and other advanced features
311311
because it is entirely written in PHP. This one can be used in any PHP
312312
application.
313313

314-
Because all clients implement the exact same API, you can switch from one to
314+
Because all clients implement the same API, you can switch from one to
315315
another just by calling the appropriate factory method, resulting in a good
316316
trade-off for every single test case: if JavaScript is needed or not, if an
317317
authentication against an external SSO has to be done, etc.
@@ -355,10 +355,10 @@ Testing Real-Time Applications
355355
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
356356

357357
Panther provides a convenient way to test applications with real-time
358-
capabilities which use `Mercure`_, `WebSocket`_ and similar technologies.
358+
capabilities that use `Mercure`_, `WebSocket`_ and similar technologies.
359359

360360
The ``PantherTestCase::createAdditionalPantherClient()`` method can create
361-
additional, isolated browsers which can interact with other ones. For instance,
361+
additional, isolated browsers that can interact with other ones. For instance,
362362
this can be useful to test a chat application having several users
363363
connected simultaneously::
364364

@@ -451,6 +451,22 @@ To use a proxy server, you have to set the ``PANTHER_CHROME_ARGUMENTS``:
451451
# .env.test
452452
PANTHER_CHROME_ARGUMENTS='--proxy-server=socks://127.0.0.1:9050'
453453
454+
Using Selenium With the Built-In Web Server
455+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
456+
457+
If you want to use `Selenium Grid`_ with the built-in web server, you need to
458+
configure the Panther client as follows::
459+
460+
$client = Client::createPantherClient(
461+
options: [
462+
'browser' => PantherTestCase::SELENIUM,
463+
],
464+
managerOptions: [
465+
'host' => 'http://selenium-hub:4444', // the host of the Selenium Server (Grid)
466+
'capabilities' => DesiredCapabilities::firefox(), // the capabilities of the browser
467+
],
468+
);
469+
454470
Accepting Self-Signed SSL Certificates
455471
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
456472

@@ -597,14 +613,22 @@ behavior:
597613
Toggle the browser's dev tools (default ``enabled``, useful to debug)
598614
``PANTHER_ERROR_SCREENSHOT_ATTACH``
599615
Add screenshots mentioned above to test output in junit attachment format
616+
``PANTHER_NO_REDUCED_MOTION``
617+
Disable non-essential movement in the browser (e.g. animations)
618+
619+
.. versionadded:: 2.2.0
620+
621+
The support for the ``PANTHER_NO_REDUCED_MOTION`` env var was added
622+
in Panther 2.2.0.
600623

601624
Chrome Specific Environment Variables
602625
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
603626

604627
``PANTHER_NO_SANDBOX``
605628
Disable `Chrome's sandboxing`_ (unsafe, but allows to use Panther in containers)
606629
``PANTHER_CHROME_ARGUMENTS``
607-
Customize Chrome arguments. You need to set ``PANTHER_NO_HEADLESS`` to fully customize
630+
Customize Chrome arguments. You need to set ``PANTHER_NO_HEADLESS`` to ``1``
631+
to fully customize
608632
``PANTHER_CHROME_BINARY``
609633
To use another ``google-chrome`` binary
610634

@@ -616,12 +640,33 @@ Firefox Specific Environment Variables
616640
``PANTHER_FIREFOX_BINARY``
617641
To use another ``firefox`` binary
618642

643+
Changing the Size of the Browser Window
644+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
645+
646+
It's possible to control the size of the browser window. This also controls the
647+
size of the screenshots.
648+
649+
This is how you would do it with Chrome::
650+
651+
$client = Client::createChromeClient(null, ['--window-size=1500,4000']);
652+
653+
You can achieve the same thing by setting the ``PANTHER_CHROME_ARGUMENTS`` env
654+
var to ``--window-size=1500,4000``.
655+
656+
On Firefox, here is how you would do it::
657+
658+
use Facebook\WebDriver\WebDriverDimension;
659+
660+
$client = Client::createFirefoxClient();
661+
$size = new WebDriverDimension(1500, 4000);
662+
$client->manage()->window()->setSize($size);
663+
619664
.. _panther_interactive-mode:
620665

621666
Interactive Mode
622667
----------------
623668

624-
Panther can make a pause in your tests suites after a failure.
669+
Panther can make a pause in your test suites after a failure.
625670
Thanks to this break time, you can investigate the encountered problem through
626671
the web browser. To enable this mode, you need the ``--debug`` PHPUnit option
627672
without the headless mode:
@@ -709,7 +754,7 @@ Here is a minimal ``.travis.yaml`` file to run Panther tests:
709754
710755
language: php
711756
addons:
712-
# If you don't use Chrome, or Firefox, remove the corresponding line
757+
# If you don't use Chrome or Firefox, remove the corresponding line
713758
chrome: stable
714759
firefox: latest
715760
@@ -788,7 +833,7 @@ The following features are not currently supported:
788833
* Updating existing documents (browsers are mostly used to consume data, not to create webpages)
789834
* Setting form values using the multidimensional PHP array syntax
790835
* Methods returning an instance of ``\DOMElement`` (because this library uses ``WebDriverElement`` internally)
791-
* Selecting invalid choices in select
836+
* Selecting invalid choices in the select
792837

793838
Also, there is a known issue if you are using Bootstrap 5. It implements a
794839
scrolling effect which tends to mislead Panther. To fix this, we advise you to
@@ -875,3 +920,4 @@ documentation:
875920
.. _`LiipFunctionalTestBundle`: https://github.com/liip/LiipFunctionalTestBundle
876921
.. _`PHP built-in server`: https://www.php.net/manual/en/features.commandline.webserver.php
877922
.. _`Functional Testing tutorial`: https://symfonycasts.com/screencast/last-stack/testing
923+
.. _`Selenium Grid`: https://www.selenium.dev/documentation/grid/

0 commit comments

Comments
 (0)