Continuous Testing in the Cloud
Using Selenium, Sauce Labs, GitHub, and Travis-CI
What is Continuous Integration?
“Continuous Integration (CI) is a
development practice that requires
developers to integrate code into a shared
repository several times a day. Each check-
in is then verified by an automated build,
allowing teams to detect problems early.”
http://www.thoughtworks.com/continuous-integration
Our Continuous Integration Process
1. Create automated functional tests with Selenium
2. Our functional tests will run on Sauce Labs’ hosted
browsers
3. Push our code changes to our hosted repository in
GitHub
4. Our pushes will trigger a build run by the Travis-CI
service which will run our tests on Sauce
Using Selenium for our Tests
What is Selenium?
“Selenium, also known as Selenium 2 and
WebDriver, is a UI automation toolkit used
by software developers and QA engineers
to test their web application on different
web browsers. ”
— Satya Avasarala, Selenium WebDriver Practical Guide
Working with Selenium Tests
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com/");
driver.findElement(By.id("gbqfq")).click();
driver.findElement(By.id("gbqfq")).sendKeys("sauce labs");
Selenium interacts with browser apps, like this Google search:
Demo
Using Sauce for our Test Runs
Sauce supports just about any platform you
need for your test runs!
Configuring Tests for Sauce
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com/");
driver.findElement(By.id("gbqfq")).click();
driver.findElement(By.id("gbqfq")).sendKeys("sauce labs");
RemoteWebDriver driver = new RemoteWebDriver(
new URL(“http://user:key@ondemand.saucelabs.com:80/wd/hub”),
caps);
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("browserName", “firefox");
caps.setCapability("version", "22");
caps.setCapability("platform", "LINUX");
For Sauce we replace the standard WebDriver with RemoteWebDriver:
Selenium interacts with browser apps, like this Google search:
And then we add our desired browser and platform:
Demo
Using GitHub for our Project
What is GitHub?
“GitHub is a web-based hosting service for
software development projects that use the
Git revision control system. GitHub offers
both paid plans for private repositories, and
free accounts for open source projects. ”
— http://en.wikipedia.org/wiki/GitHub
Using Travis for our Builds
What is Travis-CI?
“Travis-CI is a hosted, distributed
continuous integration service used to
build and test projects hosted at GitHub.
Travis-CI automatically detects when a
commit has been made and will try to
build the project and run tests.”
— http://en.wikipedia.org/wiki/Travis_CI
Configuring Travis for Sauce
gem install travis
travis init
travis encrypt SAUCE_USERNAME=your_sauce_username --add
travis encrypt SAUCE_ACCESS_KEY=XXXXXXXXXXXXXXXXX --add
Next, initialize your project for use with Travis CI:
First, install the Travis gem locally:
We need to encrypt our credentials for safe use in GitHub:
language: java
jdk:
- oraclejdk7
env:
global:
- secure: HOTmOq6r+fjDDvr7gzETG7rS9IQtZ7QQ=
- secure: NFM+4hE1VdaGs/lhaiVdn9Vi9P5L8Nb2t=
addons:
sauce_connect: true
.travis.yml example
Configuring GitHub for Travis
git add .travis.yml
git push origin master
..and commit our changes
Now we add our Travis config file to our GitHub project:
READY TO BUILD!!!
Q&A

Continuous Testing in the Cloud

  • 1.
    Continuous Testing inthe Cloud Using Selenium, Sauce Labs, GitHub, and Travis-CI
  • 2.
    What is ContinuousIntegration? “Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check- in is then verified by an automated build, allowing teams to detect problems early.” http://www.thoughtworks.com/continuous-integration
  • 3.
    Our Continuous IntegrationProcess 1. Create automated functional tests with Selenium 2. Our functional tests will run on Sauce Labs’ hosted browsers 3. Push our code changes to our hosted repository in GitHub 4. Our pushes will trigger a build run by the Travis-CI service which will run our tests on Sauce
  • 4.
  • 5.
    What is Selenium? “Selenium,also known as Selenium 2 and WebDriver, is a UI automation toolkit used by software developers and QA engineers to test their web application on different web browsers. ” — Satya Avasarala, Selenium WebDriver Practical Guide
  • 6.
    Working with SeleniumTests WebDriver driver = new FirefoxDriver(); driver.get("https://www.google.com/"); driver.findElement(By.id("gbqfq")).click(); driver.findElement(By.id("gbqfq")).sendKeys("sauce labs"); Selenium interacts with browser apps, like this Google search:
  • 7.
  • 8.
    Using Sauce forour Test Runs
  • 9.
    Sauce supports justabout any platform you need for your test runs!
  • 10.
    Configuring Tests forSauce WebDriver driver = new FirefoxDriver(); driver.get("https://www.google.com/"); driver.findElement(By.id("gbqfq")).click(); driver.findElement(By.id("gbqfq")).sendKeys("sauce labs"); RemoteWebDriver driver = new RemoteWebDriver( new URL(“http://user:key@ondemand.saucelabs.com:80/wd/hub”), caps); DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability("browserName", “firefox"); caps.setCapability("version", "22"); caps.setCapability("platform", "LINUX"); For Sauce we replace the standard WebDriver with RemoteWebDriver: Selenium interacts with browser apps, like this Google search: And then we add our desired browser and platform:
  • 11.
  • 13.
    Using GitHub forour Project
  • 14.
    What is GitHub? “GitHubis a web-based hosting service for software development projects that use the Git revision control system. GitHub offers both paid plans for private repositories, and free accounts for open source projects. ” — http://en.wikipedia.org/wiki/GitHub
  • 16.
    Using Travis forour Builds
  • 17.
    What is Travis-CI? “Travis-CIis a hosted, distributed continuous integration service used to build and test projects hosted at GitHub. Travis-CI automatically detects when a commit has been made and will try to build the project and run tests.” — http://en.wikipedia.org/wiki/Travis_CI
  • 18.
    Configuring Travis forSauce gem install travis travis init travis encrypt SAUCE_USERNAME=your_sauce_username --add travis encrypt SAUCE_ACCESS_KEY=XXXXXXXXXXXXXXXXX --add Next, initialize your project for use with Travis CI: First, install the Travis gem locally: We need to encrypt our credentials for safe use in GitHub:
  • 19.
    language: java jdk: - oraclejdk7 env: global: -secure: HOTmOq6r+fjDDvr7gzETG7rS9IQtZ7QQ= - secure: NFM+4hE1VdaGs/lhaiVdn9Vi9P5L8Nb2t= addons: sauce_connect: true .travis.yml example
  • 20.
    Configuring GitHub forTravis git add .travis.yml git push origin master ..and commit our changes Now we add our Travis config file to our GitHub project: READY TO BUILD!!!
  • 21.

Editor's Notes

  • #2  .
  • #5  .
  • #9  .
  • #14  .
  • #17  .
  • #20  Why should customers care about out product? Sell the dream of a better future 1. Deliver a story or statement that arouses the audience’s interest Sauce Labs was founded 4 years ago by Jason Huggins (inventor of Selenium), Steve Hazel and John Dunham, with the goal of making testing awesome.   2. Pose a problem or question that has to be solved or answered Cross browser lab maintenance. How much time and money will it take you to setup and maintain on internal grid   3. Offer a solution to the problem you raised Sauce’s client cloud   4. Describe specific benefits for adopting the course of action set forth in your solution  Time sand money savings 5. State a call to action