@@ -111,12 +111,12 @@ Here is an example of a snippet that uses Panther to test an application::
111
111
$client->clickLink('Getting started');
112
112
113
113
// 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 ');
115
115
// 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 ');
117
117
118
118
// 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();
120
120
// take a screenshot of the current page
121
121
$client->takeScreenshot('screen.png');
122
122
@@ -305,13 +305,13 @@ faster. Two alternative clients are available:
305
305
* The second leverages :class: `Symfony\\ Component\\ BrowserKit\\ HttpBrowser `.
306
306
It is an intermediate between Symfony's kernel and Panther's test clients.
307
307
``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
309
309
any webpage, not only the ones of the application under test.
310
310
However, HttpBrowser doesn't support JavaScript and other advanced features
311
311
because it is entirely written in PHP. This one can be used in any PHP
312
312
application.
313
313
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
315
315
another just by calling the appropriate factory method, resulting in a good
316
316
trade-off for every single test case: if JavaScript is needed or not, if an
317
317
authentication against an external SSO has to be done, etc.
@@ -355,10 +355,10 @@ Testing Real-Time Applications
355
355
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
356
356
357
357
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.
359
359
360
360
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,
362
362
this can be useful to test a chat application having several users
363
363
connected simultaneously::
364
364
@@ -451,6 +451,22 @@ To use a proxy server, you have to set the ``PANTHER_CHROME_ARGUMENTS``:
451
451
# .env.test
452
452
PANTHER_CHROME_ARGUMENTS=' --proxy-server=socks://127.0.0.1:9050'
453
453
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
+
454
470
Accepting Self-Signed SSL Certificates
455
471
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
456
472
@@ -597,14 +613,22 @@ behavior:
597
613
Toggle the browser's dev tools (default ``enabled ``, useful to debug)
598
614
``PANTHER_ERROR_SCREENSHOT_ATTACH ``
599
615
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.
600
623
601
624
Chrome Specific Environment Variables
602
625
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
603
626
604
627
``PANTHER_NO_SANDBOX ``
605
628
Disable `Chrome's sandboxing `_ (unsafe, but allows to use Panther in containers)
606
629
``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
608
632
``PANTHER_CHROME_BINARY ``
609
633
To use another ``google-chrome `` binary
610
634
@@ -616,12 +640,33 @@ Firefox Specific Environment Variables
616
640
``PANTHER_FIREFOX_BINARY ``
617
641
To use another ``firefox `` binary
618
642
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
+
619
664
.. _panther_interactive-mode :
620
665
621
666
Interactive Mode
622
667
----------------
623
668
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.
625
670
Thanks to this break time, you can investigate the encountered problem through
626
671
the web browser. To enable this mode, you need the ``--debug `` PHPUnit option
627
672
without the headless mode:
@@ -709,7 +754,7 @@ Here is a minimal ``.travis.yaml`` file to run Panther tests:
709
754
710
755
language : php
711
756
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
713
758
chrome : stable
714
759
firefox : latest
715
760
@@ -788,7 +833,7 @@ The following features are not currently supported:
788
833
* Updating existing documents (browsers are mostly used to consume data, not to create webpages)
789
834
* Setting form values using the multidimensional PHP array syntax
790
835
* 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
792
837
793
838
Also, there is a known issue if you are using Bootstrap 5. It implements a
794
839
scrolling effect which tends to mislead Panther. To fix this, we advise you to
@@ -875,3 +920,4 @@ documentation:
875
920
.. _`LiipFunctionalTestBundle` : https://github.com/liip/LiipFunctionalTestBundle
876
921
.. _`PHP built-in server` : https://www.php.net/manual/en/features.commandline.webserver.php
877
922
.. _`Functional Testing tutorial` : https://symfonycasts.com/screencast/last-stack/testing
923
+ .. _`Selenium Grid` : https://www.selenium.dev/documentation/grid/
0 commit comments