Codeception 1.7: WebDriver
Published on October 11, 2013
This is new Codeception with awaited WebDriver module in it. WebDriver module is new incarnation of Selenium implementation. As it was mentioned in previous post this WebDriver module is based on facebook/php-webdriver bindings. The most valuable thing in new Selenium bindings that they can be used just the same way Selenium is used in Java. It’s very important project for PHP community, and we say “thank you” to all the Facebook behind it. One day PHP will be used in acceptance testing as widely as Java or Ruby is used.
WebDriver module is pretty new, yet you may want to switch to it from Selenium2. It uses just the same interface, so migration should come smoothly. If you have issues, then no hurry, stay with Selenium2 for a while. Let’s list a few features that WebDriver module has:
Better Keyboard Manipoluation
A submit form method was implemented in WebDriver.
Common Selenium API
Thus If you got any Selenium questions any answers on StackOverflow will help you.
PHP implementation is so close to Java that you can use any answer in PHP.
You can invoke WebDriver methods directly with
You will notice a better output formatting in your console.
That’s because we migrated to Symfony Console output.
As you may know, Symfony console has 3 levels of verbosity, that can set via
Codeception now support them. If you want to get all available information about test, run with
--debug option is now equivalent for running
-vv. That’s right, you can get even more information with
vvv. The output will be improved during the development of 1.7 branch. We hope to get completely different output depending on level of verbosity set.
Cests are now much smarter then they were before.
If you were using StepObject you might wondered how can you pass step object class into it.
That was not really obvious, as by default you get Guy class defined in config.
But now you can use
guy annotation to specify which guy class to use.
Alternatively you can use
guy annotation for the method itself.
Also you can now use
after annotations to define whic methods of Cest class should be executed before the current one. Thus you can move similar actions into protected methods and invoke them via annotations.
Just by using annotations you can control the invokations of methods of the Cest class. Sure, you should define your support methods with
protected, so they won’t be executed as tests themselves. Another thing worth to mention, that callbacks defined in
after annotation will be called even the main test has failed, thus it makes them useful for clean ups.
We still maintain and bugfix 1.6 branch and there will be 1.6 bugfix releases. The old release
1.6.9 (yep, 1.6.9 was released to with minor bugfixes) can be downloaded from http://codeception.com/releases/1.6.9/codecept.phar.
Optional dependencies were removed from the core, so if you use Composer version and one of the following packages:
you should include them manually in your
If you use phar version - nothing is changed for you.
codeception.phar for update:
for composer version