Apple Sauce and Android Sauce … Yummy! (And fully supported!)

This morning the cover was taken off of two of Sauce Labs’ secret projects – Apple Sauce and Android Sauce (anyone else think it should have been named Jelly Bean Sauce? No? Ok, just me then). As a partner and friend of Sauce I had a heads-up about this a couple weeks ago and made sure that the various projects I run were compatible with it.

PHP-WebDriver

PHP-WebDriver is my fork of the Facebook PHP WebDriver bindings but has gone way beyond a simple fork and is its own project in its own right now. And is actively maintained, unlike the Facebook one. There are a number of example scripts in the repo that show off how to use these new options, but here is one anyways

<?phpnamespace WebDriver;
 
require_once(dirname(__FILE__) . '/../../PHPWebDriver/WebDriver.php');
require_once(dirname(__FILE__) . '/../../PHPWebDriver/WebDriverWait.php');
require_once(dirname(__FILE__) . '/pages/login.php');
 
class MacTest extends \PHPUnit_Framework_TestCase {
    protected static $driver;
 
    public function setUp() {
        $username = "your sauce username";
        $key = "your sauce key";
        $command_executor = "http://" . $username . ":" . $key . "@ondemand.saucelabs.com:80/wd/hub";
        self::$driver = new \PHPWebDriver_WebDriver($command_executor);
    }
 
    public function tearDown() {
        $this->session->close();
    }
 
    /**
    * @group sauce
    * @group firefox36
    */
    public function testFirefox36() {
        $caps = array();
        $caps["platform"] = 'Mac 10.6';
        $caps["version"] = '3.6';
        $this->session = self::$driver->session("firefox", $caps);
 
        $p = new SauceLoginPage($this->session);
        $p->open();
        $p->wait_until_loaded();
        $p->validate();
        $p = $p->login_as("gobblygook", "nonsense", false);
        $this->assertEquals($p->errors, "Incorrect username or password.");
    }
}

The interesting bit in this one is the platform is Mac 10.6. With this you can use ipad or iphone (and a bunch others, see the browser combo list).

In order to get this to work, you need to have at least PHP-WebDriver 1.1.0.

Oh! And its using a page object … more on that later in the week.

SaunterPHP

SaunterPHP is my open-source automation framework that uses PHP-WebDriver under the hood to get teams doing ‘good’ automation quickly. Page Objects, external config, CI integration … and of course Sauce OnDemand. Keeping with the design goal of not needing to change a script to change execution information, adding these new environments is just a string change in the saunter.inc file.

$GLOBALS['settings'] = array(
  "sauce.ondemand" => True,
  "sauce.get_video" => False,
  "sauce.get_log" => False
);
 
$GLOBALS['settings']['browser'] = json_encode(array(
    "username" => $GLOBALS['saucelabs']['username'],
    "access-key" => $GLOBALS['saucelabs']['key'],
    "os" => "LINUX", 
    "browser" => "android",
    "browser-version" => "4"
));

For these new environments to work, you will need to have SaunterPHP 1.0.6 or newer.

Py.Saunter

Py.Saunter is the Python variant of Saunter and has all the same features and opinions as SaunterPHP, it is just configured differently. This time in saunter.ini.

[SauceLabs]
ondemand: true
get_video: true
get_log: false
username: your username
key: your key
server_host: ondemand.saucelabs.com 
server_port: 4444
os: MAC
browser: ipad
browser_version: 4.3

For Py.Saunter users to get the new environments, you need to be running 0.49 or newer.

Maitre D

One thing that I don’t give enough play to is the fact that I (Element 34) am parter with Sauce Labs. If you are interested in setting up OnDemand into your automation mix (and you should!) email me and we can chat about how best to do it. I also have the magic partner discount code…

Post a Comment

Your email is never published nor shared. Required fields are marked *