Test::Right: Browser testing done right

May 5th, 2011 by Steven Hazel

Okay, honesty time: browser testing sucks. It’s stuck in the stone age. Browser tests are great when they’re working well, but they’re way too hard to get right, way too expensive to maintain, and just overall not a lot of fun. That’s because existing tools lead us to build brittle, sequential tests that can be clobbered by tiny application tweaks. What starts as straightforward test creation ends up with data, actions, and selectors thrown together in a big mess. We paper over the mess with abstractions like Cucumber and Capybara, but we haven’t addressed the fundamental issues.

We’re the cavemen of browser tests.

Fundamentally, these are the problems with browser tests as they’re written today:

  • Getting started is hard. It’s important to structure your tests in a way that will work out well long-term, but guidance is scarce.
  • Browser tests are brittle. Small changes in the DOM, in application performance, or in other tests often generate a lot of menial labor to repair tests. A single DOM change in your application can easily cascade into hundreds of broken tests — and cost staff days to fix them.
  • Browser tests are slow. The solution is to run many tests in parallel, but current testing frameworks lead us to write tests that don’t parallelize well.

All this makes writing and maintaining tests an expensive, and more importantly unpleasant activity.

We can do better. It’s time for a new way. As an industry, we know how to do this a lot better than we’re managing to in most cases. It’s time to accept a standard, move on, and get things done.

Test::Right aims to be that standard.

The ultimate goal of Test::Right is to make it impossible to write bad tests. That’s right, read it again. Impossible to write bad tests. That’s a serious goal, but we’re serious about it.

Are we there yet? No. But we’re a whole hell of a lot closer than anything popular out there today.

Our philosophy in creating Test::Right is to directly address the problems with browser testing from the start:

  • To make it easy to get started, test authors need an opinionated framework that chooses a thoughtful structure for tests based on our extensive experience working with large test suites.
  • To make browser tests less brittle, we have decoupled intentions from mechanics. Stable intentions like “log in” and “check account status” are disentangled from volatile mechanisms like “click the DOM element identified by this CSS selector”. We isolate the parts of tests that change frequently in a single place instead of scattering and duplicating them throughout tests, making tests robust and maintenance easy.
  • To make browser test suites run faster, we parallelize your tests from day one. Your builds will always be fast, and because every build checks that your tests run in parallel, you’ll never develop performance problems that will bite you later.

Test::Right is an idea whose time has come, born of dozens of on-site integrations of our service in household-name companies and some not-so-household name places. We as a small team have seen more browser test badness than any sane person should have to, and the tools are at fault. Test::Right is designed to address the mainstream case we’ve had the privilege to experience over the past 16 months.

We’re releasing it as a work in progress, but it already has a ton of useful functionality. We’ve put a stake in the ground with a whole slew of opinions that are sure to get a discussion started. And that’s really where we need you.

We built Test::Right by borrowing concepts from the Page Object model, but went even further by enforcing clean separation of concerns. With Test::Right, your test cases are defined in terms of actions and properties on widgets. A widget is a piece of functionality present on one or more pages of your application. A single page can have many widgets, and multiple copies of a widget may appear on the same page. Tests are grouped by feature, and tests don’t have direct access to the underlying Selenium object.

  • Widgets bring the Page Object concept into the Ajax age and decouple tests from DOM, making it far easier to adapt to frontend tweaks. They give your tests an application-specific vocabulary that maps directly to what users do with your app, and let tests make assertions about high-level aspects of your app, instead of low-level DOM state.
  • Automatic spin asserts ensure that your assertions work as you expect them to, even with Ajax.
  • Out-of-the-box parallelization gives you speed and scalability from day one.
  • Random test ordering prevents you from writing bad tests that serially build up state, depend heavily on one another, and can’t be parallelized.
  • Data factory generates isolated test data so that tests don’t clobber each other.

Test::Right is in Ruby because it seemed like a good place to start. We believe these ideas make as much sense in any other language.

Whether or not you use Test::Right, we want you to come away from it with ideas and opinions. The browser testing community needs to wake up and start writing good tests, and with Test::Right we’re going to make that happen.

And I, personally, look forward to hashing out the future of browser automation with you.

Check out the Test::Right source code on GitHub to get started. Let us know what you think, and enjoy!

Share

How to do Selenium with PHPUnit on Sauce

February 27th, 2011 by joe

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 website, and that Sauce OnDemand is the way to use Selenium. Since you want to do the right thing and use Sauce, I have two (2) pieces of good news for you:

  1. I wrote this post on how to use Sauce and PHP to test your website
  2. You’re reading it

Okay, PHP has this cool thing called pear that you can use to download useful php scripts. We’ll spend pretty much this whole blog post getting pear, then using it to get the Sauce OnDemand pear package and all of the other pear packages it depends on.

Things to know about pear:

  • You download pear packages from channels.
  • Most of the time, when you need a package, you first have to tell pear about the channel. Pear calls this “discovering” the channel.
  • If a package depends on another package, it will tell you about the other package you need, but it won’t automatically go get it for you.
  • There’s a new version of pear called Pyrus and we aren’t going to use it

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

Get Pear

This part depends on what operating system you’re using. Below are the easiest ways I’ve found to install pear for each OS. If they don’t work for you, you can always follow the instructions on the pear website.

Mac

Get mac ports. Then:
$sudo port install php5 +pear
This might complain that you don’t have all of the stuff php5 needs to install. If it does, it should also tell you what you need to do to wrap that up.

Linux

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

Windows

There’s a php installer here you can use to reinstall php. One of the steps (shown here) lets you install pear along with php. That’s all you need to do.

Now that you have pear

The rest of your setup happens from the command line. If you’re a linux or mac person, you’re already there. Windows people, push windows key+R, type “cmd”, and push enter; when you see a black window with “C:\>” in it, you’re at a command prompt and you’re ready to proceed.

First, upgrade pear:

  • pear upgrade pear

Next, discover and update all the channels we’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, finally, install 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 your account page):

  • sauce configure <account name> <access key>

If you don’t have an account name and access key, then it’s time to sign up for Sauce OnDemand!

You’re ready to cook with hot sauce

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

<?php

require_once 'PHPUnit/Extensions/SeleniumTestCase/SauceOnDemandTestCase.php';

class ExampleTest extends PHPUnit_Extensions_SeleniumTestCase_SauceOnDemandTestCase {

    function setUp() {
        $this->setOs('Windows 2003');
        $this->setBrowser('firefox');
        $this->setBrowserVersion('3.6.');
        $this->setBrowserUrl('http://example.saucelabs.com');
    }

    function test_example() {
        $this->open('/');
        $this->assertTitle('Cross browser testing with Selenium - Sauce Labs');
    }
}

Notice that the filename, ExampleTest.php, is the same as the name of the test class.
Get excited, because here’s where we finally use Sauce OnDemand:

  • phpunit ExampleTest.php

Congratulations! You ran a job with Sauce OnDemand. Go to your jobs page to see it. From here, you can edit the example test to open your own website instead of example.saucelabs.com, and add clicks and assertions to your brain’s content.

Share

Selenium 2 Testing in the Cloud

February 2nd, 2011 by shiss

Sauce Labs Introduces Selenium 2 Testing in the Cloud to Accelerate Web and Mobile Application Development

WebDriver project combines with Selenium project to create next-generation testing framework

SAN FRANCISCO, Calif. February 2, 2011 – Sauce Labs, the web application testing company, today introduced Selenium 2 support as part of its flagship cloud application testing service. Selenium 2 is the result of collaboration in the Selenium community to integrate the WebDriver project with the Selenium project. With over 4 million downloads in just 4 years, the Selenium project is one of the world’s most popular software testing frameworks for web applications.

“The focus of Selenium 2 has been our users. When your Selenium tests pass, you can be confident that your applications will work for your users,” said Simon Stewart, original creator of WebDriver and Senior Software Engineer in Test at Google. “I’m extremely pleased to see Sauce Labs carry this attention to the user from the open source project to their Sauce OnDemand service. Also, it’s extremely cool to have a video of each and every test that is run!”

Advances in Selenium 2 allow Selenium to work more tightly with browsers, offering high fidelity emulation of interactions such as clicking and typing so companies can ensure the performance of their web applications across the diverse base of browsers in use today. Key advances include:

  • Support for iPhone and Android testing – Selenium 2 includes built-in Android and iPhone emulators to allow developers and QA teams to expand their use of Selenium to support the growing demand for mobile applications. Mobile application testing will be available on Sauce OnDemand in Q1 2011, but users of the service can take advantage of all other new features in Selenium 2 today.
  • New API – The Selenium 2 API is more developer friendly and is also conceptually simpler because it directs users to focus on only two basic objects: WebDriver (browsers) and WebElements (anything on a web page) to construct tests. Selenium provides API libraries for most modern programming languages. In Selenium 2, every API library has been tailored to each programming language for easier usability.
  • Improved architecture – Selenium 2 now features more advanced automation bindings for each browser to provide the best, most stable way to test applications. The low-level approach that Selenium 2 uses to control browsers is a more solid base for the project to add features for currently supported browsers, and provides a better framework for supporting more browsers in the future.
  • Enhanced scalability – The new Selenium 2 architecture allows developers and QA teams to “scale up and down”. When a developer or QA wants to test locally on a single machine, Selenium 2 is more streamlined and “scales down” — no longer requiring the use of a background server process to control the browser from their test scripts. Therefore, simple test scenarios only call for a simplified test infrastructure. However, when teams want to run tests across multiple machines with multiple browser configurations, Selenium still retains the power necessary to handle upward scaling needs.

To learn more, register here for the Sauce Labs webinar Selenium 2: The next-generation of web and mobile application testing – hosted by Jason Huggins, creator of Selenium and co-founder of Sauce Labs, on Wednesday, February 16th at 10 a.m. Pacific Time.

“Selenium sparked a revolution when it was released in 2004. We didn’t have the options for testing Ajax applications that we have today, and it was all too common to have a QA team test by hand. Selenium 2 has fomented another revolution in testing web applications, making it feasible to test this kind of application without the overhead and workarounds that the first evolution of Selenium necessitated,” said Julian Simpson, Principal Consultant at The Build Doctor. “Sauce Labs is another kind of revolution, making it easy for anybody to enjoy Selenium 2′s ease of testing with freedom from the tyranny of deploying an array of browsers and operating systems. Using Sauce OnDemand is worth it to avoid Internet Explorer 6 alone.”

“At Sauce Labs, we’re proud to provide a Selenium 2 offering that delivers one of the most robust testing experiences for web and mobile applications available today,” said Jason Huggins, original creator of the Selenium project and co-founder of Sauce Labs. “Selenium 2 is a significant advancement for application testing because it moves beyond some of the previous challenges in Selenium 1’s architecture and provides a stable base for enhancing the entire tool chain. We’re confident Selenium 2 will prove to be very compelling for developers and QA teams alike.”

Developers and testers can use it now, with more information in the documentation.

Share

PBworks Accelerates Competitive Edge with Sauce OnDemand

December 16th, 2010 by The Sauce Labs Team

Developer productivity surges 3-4x with automated, cloud-based Selenium testing from Sauce Labs

SAN FRANCISCO, CA — (December 16, 2010) — Sauce Labs, the Selenium company, today announced that PBworks, the world’s leading provider of hosted collaboration solutions for business and education, has standardized its QA and development teams on Sauce OnDemand, the cross-browser testing service based on the Selenium testing framework.

As a result, developer productivity increased 3-4x which has enabled PBworks to deliver new features and product updates to customers in days, instead of weeks or months. “One QA manager using Sauce OnDemand does the work of what took 70 people at my previous company, There.com,” said David Weekly, founder and chief product officer of PBworks.

PBworks serves millions of users per month, including many of the world’s largest businesses, advertising agencies, law firms, and educational institutions. It’s a competitive market, and to stay ahead, the company needs to roll out new features much more quickly while fixing technical issues before they become problems for customers. The responsibility of this falls on the QA team, led by Ian Danforth, who tells the story of their path to success using Sauce OnDemand in a just-released video.

Prior to using the Sauce OnDemand cloud service, Danforth and his team used Selenium Grid. While this was a better solution than manual testing, it still required the management of hardware needed to support multiple browsers and operating systems. When Sauce Labs introduced Sauce OnDemand, Danforth saw an opportunity to move all Selenium-based functional testing to the cloud and remove the operational overhead of managing their own testing grid.

“Sauce OnDemand delivers instant scalability and cost savings,” said Danforth. “For anyone developing web applications today, using the cloud for functional testing is the only way to go because it saves you the time and money required to build and maintain an infrastructure that successful companies will invariably outgrow. We push new code twice a week, so if there is an issue or urgent customer feature request, the change can be implemented in just a few days.”

Sauce OnDemand has allowed PBworks to successfully scale their infrastructure and increase the number of tests they run without dealing with procuring, configuring, installing and maintaning physical hardware on-premise. Due to the inherent scalability of the cloud and ability to run tests in parallel, when using Sauce OnDemand, the feedback is almost immediate, and the service so reliable that developers are willing to write more functional tests because they’re confident they will function dependably. With Sauce OnDemand, PBworks is pushing the limits of what it can do as a development and QA organization.

“As development teams move closer and closer to continuous integration and agile, automated cross-browser testing becomes a critical component,” said John Dunham, CEO of Sauce Labs. “The impact Sauce OnDemand has had on PBworks in terms of scalability, reliability and meaningful feedback affirms the work we’ve put into delivering the best cloud-based testing service possible.”

Share

The Motley Fool Makes a Wise Investment in Sauce Labs Technology

November 10th, 2010 by The Sauce Labs Team

Don’t take it from us that teams who invest a little time in using Sauce OnDemand see a great ROI.

Dave Haeffner met Jason Huggins after a talk at Agile2009, and now the team at The Motley Fool has made it part of their development cycle to run tests on the browsers hosted by Sauce Labs.

What did Haeffner and his crew discover from sending tests to our browsers instead of their own?

Read The Motley Fool Case Study to find out how the Fool sped up testing 10X, slashed dev wait times and gained velocity with Sauce Labs.

Share

Sauce Labs on FIFA: Replay or Regret!

June 29th, 2010 by The Sauce Labs Team

While FIFA officials agonize whether to offer instant replay as part of their soccer match officiating regimen, Sauce Labs users experience no such stress. Sauce Labs users enjoy as a default, instant replay on all their tests, making judgment calls about what when wrong both easy and repeatable.

So for all those England fans, cheer on the mantra with us “Replay or Regret” and Sauce will keep the noise going on our end (we promise not to use vuvuzela’s).

Share

Scheduled Downtime on Saturday, August 15th

August 8th, 2009 by Steven Hazel

We’ll have some scheduled downtime next weekend for stability and performance improvements.  One major theme of this set of upgrades is the introduction of graceful upgrade paths for major components, to reduce the need for scheduled downtime in the future. We expect to be down for 4 hours beginning at 1 PM PDT (2000 UTC) on Saturday August 15th.

Share

Scheduled Downtime on Sunday, July 5th

July 4th, 2009 by Steven Hazel

We’ll have some scheduled downtime this weekend for upgrades and stability improvements.  We expect to be down for 4 hours beginning at 1 PM PDT (2000 UTC) on Sunday, July 5th.

Share