Archive for January, 2012

Video Record your Selenium Tests

When a Selenium test fails, you usually get a clear error message or trace to indicate where the problem is located. A video of your Selenium test will offer even more help in finding out just why your Selenium test failed.
By video-recording your Selenium test, you can track down when and where a problem occurs.

We at TestingBot video record every Selenium test on our grid.
When a test fails, you can log into our member area, click the failed test and see a video of your test.
This video is also available through our API, so you can easily integrate this feature into your Continuous Integration system.

Together with a video, we also take a full-screen screenshot of every single step in your test. This provides for another method to examine your tests.
These screenshots are available in our member area or by accessing our API.

It’s important to note that video recording your test does not slow down the execution of your test.
We use the Windows built-in screen recording capabilities, which uses very little CPU.

The video is recorded into a WMV file, then later encoded to an FLV file on a separate server, before it’s available to the customer. This process takes between 1 and 3 minutes to complete.

Below is a Ruby code example of running a test and grabbing the video and screenshots from our API.

require "rubygems"
gem "selenium-client"
require "selenium/client"
gem 'test-unit'
require 'test/unit'

gem "testingbot"
require "testingbot"

class ExampleTest < TestingBot::TestCase
attr_reader :browser
  def setup
     browser = Selenium::Client::Driver.new \
        :host => "hub.testingbot.com",
        :port => 4444,
        :browser => "iexplore",
        :version => "9",
        :platform => "WINDOWS",
        :url => "http://testingbot.com",
        :timeout_in_second => 60

    browser.start_new_browser_session
  end

  def teardown
    browser.close_current_browser_session
  end

  def test_page_open
    browser.open "/"
    p browser.session_id
  end
end

This code will return a String with the session_id of the test (a unique identifier for the test).
For example, the session_id we receive is: “7f5br7939150a9f199d2215920403e83″

You can then query our API to fetch the video and screenshots of this test:

curl -u key:secret http://api.testingbot.com/v1/tests/7f5br7939150a9f199d2215920403e83

This call will return a JSON formatted string with the following data:

				{
					"created_at":"2012-01-20T23:21:23Z",
					"extra":null,
					"id":121453,
					"name":"ExampleTest::test_page_open",
					"session_id":"7f5br7939150a9f199d2215920403e83",
					"status_message":"OK",
					"success":true,
					"thumbs":["https://s3.amazonaws.com/thumbtestingbot/7f5br7939150a.jpg"],
					"video":"https://s3.amazonaws.com/rectestingbot/7f5br7939150a.flv",
					"browser":"IE9",
					"os":"WINDOWS"
				}

The response contains the video URL (https://s3.amazonaws.com/rectestingbot/7f5br7939150a.flv) and the thumbnails of every step in your test.

This is just one example call to our API, for more information, please consult our API guide.

VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Mobile Testing with Selenium and Android Ice Cream Sandwich

Today we’ve added Android to our Selenium grid, which means you can now use our grid for mobile testing as well.
We’ve hooked up an Android Ice Cream Sandwich emulator to the grid, which speaks Webdriver protocol.

You can now test how your website behaves and how a page looks like on an Android cellphone by using webdriver.
An example in ruby code:

#!/usr/bin/env ruby
require "rubygems"
gem "selenium-client"
gem "selenium-webdriver"
require "selenium-webdriver"
require "selenium/client"

caps = Selenium::WebDriver::Remote::Capabilities.android
driver = Selenium::WebDriver.for(
  :remote,
  :url => "http://api_key:api_secret@hub.testingbot.com:4444/wd/hub",
  :desired_capabilities => caps)
driver.navigate.to "http://www.google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit
puts driver.title
driver.quit

Starting from today this functionality is available to all our customers.

Let us know what you think. Enjoy!

VN:F [1.9.22_1171]
Rating: 9.0/10 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Receive SMS alerts when a Selenium test fails

Today we’ve added SMS support to our alert options.
If a test fails, we can now alert you via e-mail, push notification and SMS.

Every paying plan comes with a number of available SMS messages / month.
You can set up an alert to instantly receive an SMS message as soon as a test fails, or you can choose to receive a message once a day.

The packages include the following monthly SMS credits:

  • Small Team: 5 SMS credits
  • Team: 10 SMS credits
  • Pro: 20 SMS credits
  • Enterprise: 40 SMS credits

This new alert option provides for instant feedback of your tests.
You’ll receive an alert seconds after we ran your Selenium test.
You can add an unlimited number of cellphone numbers which can be contacted when a test fails.

Thanks to Nexmo’s SMS service we reach over 200 countries, so we’re bound to support your country.

To see more features per package and to sign up, please head on over to our pricing page.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Selenium automated browser testing with C# and NUnit.

In this blog post we’ll highlight how easy it is to start testing websites with .NET framework 4 or .NET framework 3 and C#.
NUnit is built for all .NET languages and is basically a unit testing framework. It’s written in C# and integrates nicely with .NET and its features/syntax.

You can use NUnit with Visual Studio or MonoDevelop. In this example we’ll use MonoDevelop simply because it’s supported on multiple platforms.
If you don’t have MonoDevelop yet, you can get it here.

After installing MonoDevelop, create a new C# NUnit Library Project.

We can now start running unit tests with C#. To use Selenium in your unit tests, you’ll need to download the official C# Selenium client.
Once you’ve unzipped the file, you’ll have DLL files (in net40 and net35 folders, we’re using .NET 4 so net40 folder).
You need to add these DLL files to your NUnit project.

In MonoDevelop click “Project” – “Edit References”. Browse to your unpacked folder and select all the DLL files, click the add button.

You can now use the Selenium library in your unit test.
In its basic form, a unit test looks like:

using NUnit.Framework;
using System;
using Selenium;
using System.Web;
using System.Text;
using System.Net;
using OpenQA.Selenium;
using OpenQA.Selenium.Remote;

namespace Test
{
	[TestFixture()]
	public class Test
	{
		private IWebDriver driver;

        [SetUp]
        public void Init()
        {
            DesiredCapabilities capabillities = DesiredCapabilities.InternetExplorer();
            capabillities.SetCapability(CapabilityType.Version, "8");
	    capabillities.SetCapability("api_key", "...");
            capabillities.SetCapability("api_secret", "...");

            driver = new RemoteWebDriver(
                new Uri("http://hub.testingbot.com:4444/wd/hub/"), capabillities);
        }

        [Test]
        public void TestCase()
        {
            driver.Navigate().GoToUrl("http://www.google.com");
            StringAssert.Contains("Google", driver.Title);
        }

        [TearDown]
        public void Cleanup()
        {
            driver.Quit();
        }
	}
}

The

DesiredCapabilities capabillities = DesiredCapabilities.InternetExplorer();

indicates we want to run our test on an Internet Explorer browser.
The CapabilityType.Version means we want to run it on version 8 of Internet Explorer.
Don’t forget to set the api_key and api_secret values to the key and secret you received from us (available in our member area).

Every testcase we want to build should have a [Test] annotation above its function and indicate to the driver the URL that the browser should open.
For example in our TestCase function we send Selenium the command to navigate to the Google website. We then assert (verify/test) that the title of the current page (Google’s Homepage) is Google (which it is).

To run this test, click the “Run” menu item and click “Run”.
The test will now run on our Grid and should give back results in moments.

Run your Selenium tests in C#  for free on our browsers with our free trial account.
If you should have questions or remarks, please leave a comment.

VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.22_1171]
Rating: +1 (from 1 vote)

Selenium 2.16.1, ChromeDriver 18.0.995.0 and C# with NUnit

We are pleased to announce that we have updated our Selenium grid to the latest Selenium version, 2.16.1
Changes include improved stability and bugfixes. You can read the detailed changelog on the official website of the Selenium project.

This update also includes the latest ChromeDriver 18.0.995.0. You can see its changelog here.

Together with these updates we’ve also added C# support. If you’re looking to run Selenium tests with .NET framework 4 or .NET framework 3 and C# then you can use NUnit and our Selenium grid.
We’ve added examples over at the C# example page.

Expect a detailed post with a tutorial and examples for C# in the coming days.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Selenium SSL/HTTPs support

Today we’ve added SSL support to our Selenium grid, you can now test HTTPs pages without problems.
Self-signed and regular SSL certificates should be automatically accepted on our browsers.

We are using the CyberVillians certificate on Windows, which is bundled in Selenium RC, and is documented on http://blog.mogotest.com/2010/04/13/how-to-accept-self-signed-ssl-certificates-in-selenium/

There may still be some issues with Safari and self-signed certificates, if you do encounter a problem on Safari, please let us know.
Also, right now we’re redirecting all safari requests to safariproxy since it seems more stable. This should not have any effect on speed or tests.

On another note, we’ve been preparing our grid for unicode support. We’ve installed the necessary packages to support any language: from cyrillic characters to japanese Kanji.

VN:F [1.9.22_1171]
Rating: 4.0/10 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)