Codeception: A Clean and Simple Solution for Web Test Automation

Leave a comment

by Troy Rudolph, Senior Software Engineer

troy-rudolphThe market certainly offers many test automation tools for testing in a variety of environments, but there is a relatively new one I particularly like for automated testing in web applications. While Codeception is intended primarily for testing PHP applications, the UI testing tools may also be used to easily create automated tests for web applications, as well.

In Codeception, these tests are referred to as acceptance tests. These tests are based on the notion of Behavior Driven Development (BDD). Essentially, BDD states that tests should be specified in terms of desired behavior. In the case of BDD, the behavior described is that of a user (or tester). To learn more about BDD, I would encourage reading the inventor’s article at

A simple test might look like…

  1. I login
  2. I go the customer search page.
  3. I search for customer 314159.
  4. I go to the customer’s list of transactions
  5. I issue a refund for transaction 271828.

The Codeception API for acceptance tests takes this kind of thinking and runs with it. The API works at a lower level, of course, because in acceptance testing, we need to manipulate the screen elements to do our work. Here’s how the test above might look when implemented in Codeception.


The implementation of the test is indeed at a lower level than the user story, but it is not very different from it. This makes it possible for testers to implement stories more quickly and directly.

Additionally, Codeception can drive your application in a variety of ways.

Tests can be run with real browsers (Firefox, IE, Chrome, Safari) by using the Selenium Webdriver to communicate with your application. This allows you to test all of your web page implementation – even the JavaScript. PhantomJS can be used for this purpose as well. It is a headless browser that has its own WebDriver implementation; so, you wouldn’t need Selenium.

For headless testing via HTTP only, use PHPBrowser. It will drive the application properly, but will not test the JavaScript “widgets” on your web pages. And, it is faster than using “real” browsers.

Codeception is highly functional, reliable, and easy to use. The documentation at continues to improve and is more helpful today with recent changes. The code is open source and has the MIT license, thus it is all free.

So, if you are embarking on a test automation project for a web-based application, give Codeception a try and see if it doesn’t save you both time and effort.

Author: bridge360blog

Software Changes Everything.... Bridge360 improves and develops custom application software. We specialize in solving complex problems at every phase of the software development lifecycle, removing roadblocks to help our clients’ software and applications reach their full potential in any market. The Bridge360 customer base includes software companies and world technology leaders, leading system integrators, federal and state government agencies, and small to enterprise businesses across the globe. Clients spanning industries from legal to healthcare, automotive to energy, and high tech to high fashion count on us to clear a path for success. Bridge360 was founded in 2001 (as Austin Test) and is headquartered in Austin, Texas with offices in Beijing, China.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s