Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Using the Selenium Web Driver API with PHPUnit
Aug 24, 2015 @ 12:54:56

The SitePoint PHP blog has posted a tutorial showing you how to use the Selenium web driver API from inside of your PHPUnit tests. Selenium is an automation tool that makes testing frontends of applications simpler.

Previously, we demonstrated using Selenium with PHPUnit and used a user subscription form example throughout the article. In this one, we are going to explore Facebook’s webdriver package for emulating a browser. PHPUnit partially supports the Selenium WebDriver API and the work is still in progress. One of the most popular WebDriver API implementations is the Facebook/webdriver package. We will try to accomplish the same validation tests from the previous article using this package.

They help you get the Facebook package installed (via Composer) and create a first simple test class. They create an instance of the RemoteWebDriver object and point it at their local application. A test is then created to navigate to a form, fill in a bit of data and submit it. The results are then checked for a string ("Everything is Good!") to pass the test. He also shows how to have the driver wait for an element to load, possibly one that uses an AJAX request. The post finishes off with a look at some of the other interaction methods (drag and drop, handling popups) and how to run the tests in a "headless" mode not requiring a browser to execute through your system.

tagged: selenium phpunit webdriver api tutorial frontend testing

Link: http://www.sitepoint.com/using-the-selenium-web-driver-api-with-phpunit/

Working with PHPUnit and Selenium Webdriver
Nov 21, 2013 @ 12:15:43

On the Codeception site they've recently posted a guide to using PHPUnit and the Selenium Webdriver to easily create functional tests for your application. They make use of the php-webdriver library from Facebook to make the connection inside the tests.

In this post we will explore some basics of user acceptance testing with Selenium. We will do this with classical unit testing framework PHPUnit, web browser Firefox, and with new php-webdriver library recently developed by Facebook. Selenium allows us to record user actions that we do inside a browser and then automate them. PHPUnit will be used to do various assertions and check them for fallacy. And php-webdriver is used to connect PHP with Selenium, in order to do browser manipulation in PHP.

They walk you through the installation process (pretty simple with Composer) and show you how to start up a standalone Selenium server to receive the test commands. From there they start in on the test examples make with PHPUnit, first creating a simple test that connects to Github and looks for "Github" in the page title. They list some of the more complex selector functions and put them to use finding an object by ID. Finally, they include a few handy tips about locating elements, handling "not found" items and some refactoring and test structure suggestions.

tagged: phpunit selenium webdriver facebook tutorial functional testing

Link: http://codeception.com/11-12-2013/working-with-phpunit-and-selenium-webdriver.html

Selenium on Android
Apr 18, 2012 @ 12:43:04

On DZone.com there's a recent post from Giorgio Sironi looking at running Selenium tests on the Android platform via the PHPUnit Selenium interface.

Testing web applications is not only based on unit and functional tests for the server-side (PHP, Java) and client-side (JavaScript) components, but also on end-to-end tests like the ones performed with Selenium. Selenium is capable of driving a real browser like Firefox in the same way a user would do, letting you express a test with a series of page to load, element selections, clicks and typed characters. [...] In this tutorial, we'll experiment with the Android Driver and set up a couple of tests to run inside an Android virtual device.

He walks you through the basic setup of an Android environment (based on the Android SDK) and how to start up the Android driver installed from the Selenium site. An example test is included, showing how to make a request for a test page and checking its title as well as checking that the input from the "keyboard" is successful.

tagged: selenium android phpunit webdriver sdk


Selenium 2 from PHP code
Nov 16, 2011 @ 10:06:01

On DZone.com today Girogio Sironi shares some of his experiences testing out the PHP bindings currently offered to work with Selenium, the web application frontend testing tool that's become a standard over the past few years.

After trying out Selenium 2, it was natural for me to look for its support in PHP code; however, there isn't an official PHP Api distributed on Selenium's website. I tested all the PHP bindings I could find to see which is the best choice today.

He tried out a few different technologies:

The finishes the post with a quick summary for each of the offerings including strengths each has and situations where you might want to use them.

tagged: selenium frontend test integrate phpunit webdriver