How to do Selenium with PHPUnit on Sauce

Sauce AI for Test Authoring: Move from intent to executing in minutes.|xBack to ResourcesBlogPosted

June 16, 2026 · 4 min read · Tool Comparison

Sauce AI for Test Authoring: Move from intent to executing in minutes.

|

x

Back to Resources

Blog

Posted February 28, 2011

How to do Selenium with PHPUnit on Sauce

quote

So I heard you have a PHP website you want to test. I guess you already heard that Selenium is the way to test a site, and that Sauce OnDemand is the way to use Selenium. Since you desire to do the right thing and use Sauce, I have two (2) pieces of good word for you:

  1. I wrote this post on how to use Sauce and PHP to try your website

  2. You & # x27; re reading it

Okay, PHP has this cool thing callpearthat you can use to download useful php scripts. We & # x27; ll spend pretty much this whole blog post getting pear, so using it to get the Sauce OnDemand pear software and all of the other pear packages it depends on. Things to know about pear:

  • You download pear packet from channel.

  • Most of the clip, when you need a package, you first have to tell pear about the channel. Pear name this & quot; discovering & quot; the groove.

  • If a parcel depends on another bundle, it will tell you about the other parcel you take, but it won & # x27; t automatically go get it for you.

  • There & # x27; s a new version of pear called Pyrus and we aren & # x27; t going to use it

Okay. So, before we can use pear, we have to go get it.

Get Pear

This portion depends on what operating system you & # x27; re using. Below are the easy ways I & # x27; ve establish to install pear for each OS. If they don & # x27; t work for you, you can always follow theinstructions on the pear website.

Mac

Get mac ports. Then: $ sudo embrasure install php5 +pearThis might complain that you don & # x27; t hold all of the stuff php5 needs to instal. If it does, it should also tell you what you need to do to roll that up.

Linux

$ sudo apt-get update $ sudo apt-get install php-pear

Windows

There & # x27; s a php installerhereyou can use to reinstall php. One of the steps (shownhere) lets you establish pear along with php. That & # x27; s all you need to do.

Now that you have pear

The rest of your apparatus happen from the command line. If you & # x27; re a linux or mac soul, you & # x27; re already there. Windows people, push windows key+R, type & quot; cmd & quot;, and push enter; when you see a black window with & quot; C: \ & gt; & quot; in it, you & # x27; re at a command prompt and you & # x27; re ready to proceed. First, upgrade pear:

For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.

  • pear upgrade pear

Next, discover and update all the channels we & # x27; ll need to install pear packages from:

  • pear channel-discover pear.phpunit.de

  • pear channel-update pear.phpunit.de

  • pear channel-discover components.ez.no

  • pear channel-update components.ez.no

  • pear channel-discover pear.symfony-project.com

  • pear channel-update pear.symfony-project.com

  • pear channel-discover saucelabs.github.com/pear

  • pear channel-update saucelabs.github.com/pear

Now, last, instal phpunit for Sauce OnDemand:

  • pear install -a saucelabs/PHPUnit_Selenium_SauceOnDemand

Last, configure PHPUnit_Selenium_SauceOnDemand to use your Sauce Labs account and access key (which you can find at youraccount page):

  • sauce configure & lt; account gens & gt; & lt; access key & gt;

If you don & # x27; t have an account name and approach key, so it & # x27; s time tosign upfor Sauce OnDemand!

You & # x27; re ready to cook with hot sauce

You get to run tests with hot Sauce! Here & # x27; s an illustration script, and how to run it. Put the following PHP into a file named ExampleTest.php:

<?php

require_once & # x27; PHPUnit/Extensions/SeleniumTestCase/SauceOnDemandTestCase.php & # x27;;

class ExampleTest extends PHPUnit_Extensions_SeleniumTestCase_SauceOnDemandTestCase {

function frame-up () {$ this- & gt; setOs (& # x27; Windows 2003 & # x27;);
$ this- & gt; setBrowser (& # x27; firefox & # x27;);
$ this- & gt; setBrowserVersion (& # x27; 3.6. & # x27;);
$ this- & gt; setBrowserUrl (& # x27; http: //example.saucelabs.com & # x27;);
}

function test_example () {
$ this- & gt; open (& # x27; / & # x27;);
$ this- & gt; assertTitle (& # x27; Cross browser testing with Selenium - Sauce Labs & # x27;);
}
}

Notice that the filename, ExampleTest.php, is the like as the name of the tryout category. Get stimulate, because here & # x27; s where we eventually use Sauce OnDemand:

  • phpunit ExampleTest.php

Congratulations! You ran a job with Sauce OnDemand. Go to yourjobs pageto see it. From hither, you can edit the instance examination to open your own website instead of example.saucelabs.com, and add clicks and assertions to your brain & # x27; s substance.

Published:
Feb 28, 2011
Topics
Share this station
Copy Share Link
LinkedIn
© 2026 Sauce Labs Inc., all rights allow. SAUCE and SAUCE LABS are file trademarks owned by Sauce Labs Inc. in the United States, EU, and may be register in early jurisdictions.
robot
quote

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free