How to select the operating system and browser you want to run your tests on


You can choose between various Browsers and operating systems to run your test on.


After you've determined the browser and OS you want to run your test on you need to specify what you would like in your test.


Below are some examples on how to do this with Selenium rc code


PHP code

In the example below we will run the test on firefox 8

<?php

	class SimpleTest extends PHPUnit_Extensions_TestingBotTestCase
	{
	    protected function setUp()
	    {
	    	$this->setBrowserVersion(8);
	    	$this->setPlatform('Windows');
	    	$this->setBrowser('Firefox');
	    }
	}

Ruby code

In the example below we will run the test on safari 5

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 => "safari",
        :version => "5",
        :platform => "WINDOWS",
        :url => "https://testingbot.com",
        :timeout_in_second => 60
    browser.start_new_browser_session
  end

C# code

In the example below we will run the test on internet explorer 9

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, "9");
			capabillities.SetCapability("api_key", "REPLACE_API_KEY");
            capabillities.SetCapability("api_secret", "REPLACE_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();
        }
   }
}