You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mention composition to integrate with existing test tools (symfony#94)
* Mention composition to integrate with existing test tools
* also fix some wordings
* Remove "internal" tag from PantherTestCaseTrait
* Update README.md
Copy file name to clipboardExpand all lines: README.md
+39-8Lines changed: 39 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -8,23 +8,23 @@
8
8
9
9
*Panther* is a convenient standalone library to scrape websites and to run end-to-end tests **using real browsers**.
10
10
11
-
Panther is super powerful, it leverages [the W3C's WebDriver protocol](https://www.w3.org/TR/webdriver/) to drive native web browsers such as Google Chrome and Firefox.
11
+
Panther is super powerful. It leverages [the W3C's WebDriver protocol](https://www.w3.org/TR/webdriver/) to drive native web browsers such as Google Chrome and Firefox.
12
12
13
-
Panther is very easy to use, because it implements the popular Symfony's [BrowserKit](https://symfony.com/doc/current/components/browser_kit.html) and
13
+
Panther is very easy to use, because it implements Symfony's popular[BrowserKit](https://symfony.com/doc/current/components/browser_kit.html) and
14
14
[DomCrawler](https://symfony.com/doc/current/components/dom_crawler.html) APIs, and contains
15
15
all features you need to test your apps. It will sound familiar if you have ever created [a functional test for a Symfony app](https://symfony.com/doc/current/testing.html#functional-tests):
16
16
as the API is exactly the same!
17
-
Keep in mind that Panther can be used in every PHP project, it's a standalone library.
17
+
Keep in mind that Panther can be used in every PHP project, as it is a standalone library.
18
18
19
19
Panther automatically finds your local installation of Chrome and launches it (thanks to [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/)),
20
-
so you don't need to install anything on your computer, neither Selenium server nor obscure driver.
20
+
so you don't need to install anything on your computer, neither Selenium server nor any other obscure driver.
21
21
22
22
In test mode, Panther automatically starts your application using [the PHP built-in web-server](http://php.net/manual/en/features.commandline.webserver.php).
23
-
You can just focus on writing your tests or web-scraping scenario, Panther takes care of everything else.
23
+
You can focus on writing your tests or web-scraping scenario and Panther will take care of everything else.
24
24
25
25
## Install
26
26
27
-
Use [Composer](https://getcomposer.org/) to install Panther in your project. You may want to use the --dev flag if you want to use Panther for testing only and not for web scraping:
27
+
Use [Composer](https://getcomposer.org/) to install Panther in your project. You may want to use the --dev flag if you want to use Panther for testing only and not for web scraping in a production environment:
28
28
29
29
composer req symfony/panther
30
30
@@ -59,6 +59,8 @@ It extends [PHPUnit](https://phpunit.de/)'s `TestCase` and provide all testing t
59
59
```php
60
60
<?php
61
61
62
+
namespace App\Tests;
63
+
62
64
use Symfony\Component\Panther\PantherTestCase;
63
65
64
66
class E2eTest extends PantherTestCase
@@ -96,6 +98,8 @@ to authenticate to an external SSO server, do I want to access the kernel of the
96
98
```php
97
99
<?php
98
100
101
+
namespace App\Tests;
102
+
99
103
use Symfony\Component\Panther\PantherTestCase;
100
104
use Symfony\Component\Panther\Client;
101
105
@@ -116,21 +120,48 @@ class E2eTest extends PantherTestCase
116
120
// enjoy the same API for the 3 felines
117
121
// $*client->request('GET', '...')
118
122
119
-
$kernel = static::createKernel(); // You can also access to the app's kernel
123
+
$kernel = static::createKernel(); // You have also access to the app's kernel
120
124
121
125
// ...
122
126
}
123
127
}
124
128
```
125
129
130
+
### Usage with Other Testing Tools
131
+
132
+
If you want to use Panther with other testing tools like [LiipFunctionalTestBundle](https://github.com/liip/LiipFunctionalTestBundle) or if you just need to use a different base class, Panther has got you covered. It provides you with the `Symfony\Component\Panther\PantherTestCaseTrait` and you can use it to enhance your existing test-infrastructure with some Panther awesomeness:
133
+
134
+
```php
135
+
<?php
136
+
137
+
namespace App\Tests\Controller;
138
+
139
+
use Liip\FunctionalTestBundle\Test\WebTestCase;
140
+
use Symfony\Component\HttpFoundation\Response;
141
+
use Symfony\Component\Panther\PantherTestCaseTrait;
142
+
143
+
class DefaultControllerTest extends WebTestCase
144
+
{
145
+
use PantherTestCaseTrait; // this is the magic. Panther is now available.
146
+
147
+
public function testWithFixtures()
148
+
{
149
+
$this->loadFixtures([]); // load your fixtures
150
+
$client = self::createPantherClient(); // create your panther client
151
+
152
+
$client->request('GET', '/');
153
+
}
154
+
}
155
+
```
156
+
126
157
## Features
127
158
128
159
Unlike testing and web scraping libraries you're used to, Panther:
129
160
130
161
* executes the JavaScript code contained in webpages
131
162
* supports everything that Chrome (or Firefox) implements
132
163
* allows screenshots taking
133
-
* can wait for the appearance of elements loaded asynchronously
164
+
* can wait for the appearance of asynchronously loaded elements
134
165
* lets you run your own JS code or XPath queries in the context of the loaded page
0 commit comments