Subscribe via RSS or know about updates first by getting on the newsletter.
Learning to program doesn't have to be so hard. Reading scattered blog posts and books isn't as effective as watching real projects being built and actively coding along with them. SymfonyCasts bridges that learning gap, bringing you video tutorials and interactive coding activities. Code on!
Ok, we need a Panther! So... let's go to the Zoo! Or, maybe just install the digital version with Composer:
composer require robertfausk/behat-panther-extension --dev
This library integrates Panther with Behat... and though it's still pretty young, it works really well!
After it finishes, you won't find many changes to your project: only the
composer.lock files have changed. But you will see that the
post-install prints a recommendation:
Install ChromeDriver or geckodriver
Woohoo! That's something we already did! If you missed it - check out the previous blog post.
The post-install text also says:
To use Panther with PHPUnit, uncomment the snippet registering the Panther extension in
We won't be using Panther inside PHPUnit, so you can ignore this.
We now have a PantherExtension in our app, which is like a "plugin" between Behat
and Panther. To tell Behat to use it, update your
default: # ... extensions: # ... Robertfausk\Behat\PantherExtension: ~ # no configuration here Behat\MinkExtension: # ...
Now we need to configure
Here is the minimum configuration:
To run tests, open your terminal and execute:
And... woohoo, everything should work! You won't see the browser open (like you did with Selenium), but your tests are being run in a real browser. If you get an exception like:
The port 9080 is already in use. (RuntimeException)
No problem, just configure another port for Panther:
default: # ... extensions: # ... Behat\MinkExtension: # ... panther: options: port: 9081 # or another port you like browser: 'chrome'
By the way, you can find all available configuration options in PantherTestCaseTrait::$defaultOptions.
As you can see, configuring and using Panther is a bit easier than Selenium, which we like. You can find more usage examples in the robertfausk/behat-panther-extension repository
That's all folks!