Monday, 27 January 2014

Run Selenium scripts on Cloud - TestingBot | TestNG

Note:  Text in ORANGE can be edited or mentioned important for this entire blog

TestingBot provides similar Browserstack | Saucelabs setup for cloud based automation using Selenium WebDriver.  Given below is a generic test using TestNG from Eclipse IDE that run on TestingBot cloud server. 

1| Log into Testingbot.com
2| Obtain the Client Key and Client Secret from Account.
3| Make use of the following script and do edit whenever necessary.

package packagename;

import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class Classname {
private WebDriver driver;

@BeforeClass
public void setUp() throws Exception {
DesiredCapabilities capabillities = DesiredCapabilities.firefox();
capabillities.setCapability("version", "24");
capabillities.setCapability("platform", Platform.WINDOWS);
capabillities.setCapability("name", "Test01");
driver = new RemoteWebDriver(
new URL(
"http://ClientKey:ClientSecret@hub.testingbot.com:4444/wd/hub"),
capabillities);
}

@Test
public void test01() throws Exception {
driver.get("http://www.google.co.in/?gws_rd=cr&ei=zS_mUryqJoeMrQf-yICYCA");
driver.findElement(By.id("gbqfq")).clear();
WebElement element = driver.findElement(By.id("gbqfq"));
element.sendKeys("selenium");
Assert.assertEquals("selenium - Google Search", driver.getTitle());
}

@AfterClass
public void tearDown() throws Exception {
driver.quit();
}
}

4| Got to Tests Tab and get your logs.


TestingBot also lets you run the test through online site.
Follow the steps mentioned below:

1| Open Selenium IDE and record your tests.
2| Save the test suite in HTML format.
3| Log into Testingbot.com
4| Now, try to upload the tests in testingbot site... click on the link.
5| Click 'Choose File' and select already saved html file.
6| Click 'Start a test from scratch'.
7| Name the Test and provide the base URL.
8| Now, select the browser and OS platform.
9| Save settings
10| Click, 'Run this test now'.
11| Go to 'Tests' Tab and get the logs.

1 comment: