Skip to end of metadata
Go to start of metadata

In this code example for PHP, the test runs a check to make sure that clicking a link brings you to the expected page. While simple, this example illustrates everything you need to run an automated test on Sauce Labs. First, it checks for your Sauce authentication credentials, which are set as environmental variables, and then sets the platform, browser, version, and other capabilities to use in the test. 


Finding Your Username and Access Key

You can find your Sauce Labs username and access key in the User Profile > User Settings section of your Sauce Labs dashboard.

You can also clone this script directly from our GitHub repo.

<?php
  // Setup: $ php composer.phar require facebook/webdriver

  require_once('vendor/autoload.php');
  use Facebook\WebDriver\Remote\RemoteWebDriver;
  use Facebook\WebDriver\WebDriverBy;

  $web_driver = RemoteWebDriver::create(
    "https://YOUR_SAUCE_USERNAME:YOUR_SAUCE_ACCESS_KEY@ondemand.saucelabs.com:443/wd/hub",
    array("platform"=>"Windows 7", "browserName"=>"chrome", "version"=>"40")
  );
  $web_driver->get("https://saucelabs.com/test/guinea-pig");

  /*
    Test actions here...
  */

  $web_driver->quit();
?>