This is the an addition of my earler post Selenium GRID setup. The limitation Selenium Grid are,
a. This is can work only on LAN
b. Required more Virtual machiness pre-reloaded with different browsers.
c. We can not run Grid setup in internet
As a remedy for this problem, the SauceLab team who is the active supporter and co-founder of Selenium Opensource community has launched new Cloud based solutions for running web browser based tests. So we do not need to worry about system resource and just initiate the browser request from Hub server to run test at Saucelab networks.
Brief description about SauceLabs
SauceLab offers a platform for running automated or manual cross browser testing. Using their platform we can,
a. Have cross browser testing including linux,Windows, Mac, iOS and Andriod.
b. Would be helpful to CSS/Html5 designers ( UI Team) to verify the scripts in different browsers.
c. Moreover we can automate browser-based test for most of the OS platforms remotely.
How do I run the Selenium script hosted locally in Saucelab servers,
These are the basic steps,
a. Download Selenium server (selenium-server-standalone-2.32.0.jar0 from seleniumhq.org
b. Download Saucelab plug-ins for Selenium Grid (sauce-grid-plugin-1.0.4.jar) can be available at http://sauceio.com/index.php/2012/09/introducing-the-sauce-plugin-for-selenium-grid/
c. Launch the Selenium server along with SauceLab plug-in
A sample output will looks like as show below,
May 5, 2013 12:22:05 AM org.openqa.grid.selenium.GridLauncher main
INFO: Launching a selenium grid server
May 5, 2013 12:22:06 AM org.openqa.grid.web.Hub <init>
INFO: binding com.saucelabs.grid.SauceOnDemandAdminServlet to /grid/admin/SauceOnDemandAdminServlet/*
May 5, 2013 12:22:06 AM org.openqa.grid.web.Hub <init>
INFO: binding com.saucelabs.grid.SauceOnDemandConsoleServlet to /grid/admin/SauceOnDemandConsoleServlet/*
2013-05-05 00:22:06.198:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT
2013-05-05 00:22:06.240:INFO:osjsh.ContextHandler:started o.s.j.s.ServletContextHandler{/,null}
2013-05-05 00:22:06.248:INFO:osjs.AbstractConnector:Started SocketConnector@0.0.0.0:4444
Great ! next you need to enable Sauce authentication in that selenium server.
Just go to http://localhost:4444/grid/admin/SauceOnDemandConsoleServlet or the adjust the server url you’d been hosted it. Browser window will look like this,
Next you need to click on Configure Proxy link and provide your sauceLab user name and access key ( will be shown at the left side on the login window in Sauce account). and then Save the changes. See the following screen,
Perfect ! Now You’re ready to play with Saucelab clouds.
In earlier post, I have provide a sample JUnit test which can run the unit test in Selenium Grid environment.You may download that program here [70MB size] and you may need to modify the content of the file “HubNodeCommunication.java” and modify the Huburl line to http://localhost:4444/wd/hub (the selenium server port which started with SauceLab plugin). You can download the file from here.
public void setUp() throws MalformedURLException
{
baseUrl = "http://www.serveridol.com";
hubURL = "http://localhost:4444/wd/hub";
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setPlatform(Platform.LINUX);
capability.setCapability("version", "12.0");
driver = new RemoteWebDriver(new URL(hubURL), capability);
}
@Test
public void testDistributor() throws Exception {
driver.get(baseUrl + "/2013/05/04/jvm-monitoring-tool-using-jtop/");
driver.findElement(By.linkText("Auto Scaling")).click();
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
}
Then build the Jnuit project and run. You can see your test are running at Saucelab along with video pre-view and screenshots.
Hoping that you are enjoyed my class 🙂 and will have get a clear idea about running selenium scripts in Saucelab clouds.
Cheers !!!
Leave a Reply