App & Browser Testing Made Easy

Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators

Get Started free
Home Guide Why you should move your testing to a Selenium Cloud?

Why you should move your testing to a Selenium Cloud?

Shreya Bose, Technical Content Writer at BrowserStack -

What is a Selenium Cloud?

Imagine that a QA could run all their automated software tests on a Selenium framework that exists entirely on the cloud. This cloud hosts a Selenium grid that connects to a vast range of browsers and devices and allows users to execute multiple tests simultaneously using parallel testing. All this is done without any maintenance or updating activities on the part of the users. They simply create test scripts and run them on a cloud-based infrastructure that is fast, robust and available 24/7.

This is what one would call a Selenium Cloud.

Why should you move your automated tests to a Selenium Cloud?

According to a report by MarketsandMarkets, the global automation testing market is predicted to boom from $12.6 billion to $28.8 billion by 2024. This is completely unsurprising since new websites and apps are hitting the market with ever-increasing frequency. Additionally, existing websites and apps are constantly rolling out new features to improve user experience and keep users interested or entertained.

For software testers, this translates to more varied testing and tighter deadlines. In such a scenario, automation becomes indispensable. Automating repetitive tests such as regression tests, unit tests, integration tests and the likes prevent QAs from having to waste precious man-hours executing the same scripts with a few changed variables.

Automated Testing improves delivery timelines, reduces human error and offers the opportunity to scale up testing efforts with minimal effort. It is best to do all these with some kind of automation framework. The most popular of these frameworks is Selenium WebDriver, which provides a Selenium Grid. This grid is ideal for implementing automated tests across browsers and devices.

However, setting up and maintaining an in-house Selenium grid can be quite challenging, even for organizations. This is especially true when the grid has to support different combinations of browsers, devices and operating systems. Instead, a Selenium grid on cloud hosted by a reliable third-party organization can provide all the benefits of a Selenium grid without having to worry about buying and setting up new devices or maintaining current devices and browser versions. Naturally, moving automated tests on a Selenium cloud lets testers get more done with much less work.

Talk to a Solutions Expert

Optimizely Logo

Did you know: Optimizely runs 15,000+ tests in 45 minutes

Optimizely scaled its automation testing by moving from an on-premise grid to our cloud infrastructure.

BrowserStack provides a Cloud Selenium Grid that provides instant access to 2000+ real browsers and devices (real and mobile). It offers an advanced, sophisticated environment for easy automated testing. A few of the features that enable this are:

  • A Selenium grid that lets users automate a diverse range of tests across thousands of real browsers, browser versions, OSs and devices. This empowers QAs to conduct tests in real user conditions at all times.
  • Parallel testing opportunities that can accelerate build verification
  • A fast, 24/7 available infrastructure that supports all the testing in any CI pipeline.
  • Integrations with a vast range of programming languages, frameworks, and CI/CD tools designed to make testing quicker and more efficient.
  • Tools for easy Selenium debugging such as video recordings, automated screenshots of errors, text logs of every Selenium command, browser console logs, network logs and more.

How does a user set up testing on BrowserStack’s Selenium Cloud?

  1. Log in to BrowserStack and navigate to the Automate page.
  2. In the top left corner, click on the Show + button to retrieve your Username and Access Keys.

Before proceeding to the next steps, it is important to understand how BrowserStack works. The architecture is based on ‘Hubs‘ and ‘Nodes‘. The Hub is the central point that will receive all requests along with information on which browser, platform (i.e Windows or Linux) and which device the test should be run on. Based on the request received, it will distribute them to the registered nodes.

Nodes are where the corresponding tests will run. Each node is a machine (physical/virtual machine) or a real mobile device that is registered with the hub. When a node is registered, the hub receives the information of the node and it will display the browser and configuration details of the nodes.

The prerequisites for setting Automate are the Capabilities object and Remote WebDriver. The capabilities object would help to configure the desired properties and platform for the tests, and Remote WebDriver is used to hit the BrowserStack API.

Based on the preferences set in the desired capabilities instance, the Hub will point the tests to a node that matches the preferences.

Here is a sample code snippet in Java that sets the capability to point the required node to the respective hub:

final String USERNAME = "";
final String AUTOMATE_KEY = "";
final String URL = "https://" + USERNAME + ":" + AUTOMATE_KEY + "@hub-cloud.browserstack.com/wd/hub";

try
{
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("browser",browser);
caps.setCapability("browser_version",browser_version);
caps.setCapability("os",os);
caps.setCapability("os_version",os_version);
caps.setCapability("resolution",resolution);
caps.setCapability("project","Project-1");
caps.setCapability("build","1.0");
caps.setCapability("browserstack.debug","true");
caps.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
driver = new RemoteWebDriver(new URL(URL),caps);
}
catch(MalformedURLException e)
{
e.getMessage();
}

Use testng.xml to pass the browser properties as parameters. For example:

<?xml version="1.0″ encoding="UTF-8″?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite thread-count="3″ name="Suite" parallel="tests">
<test name="Test on Chrome">
<parameter name="browser" value="Chrome"/>
<parameter name="browser_version" value="43.0″/>
<parameter name="os" value="Windows"/>
<parameter name="os_version" value="7″/>
<parameter name="resolution" value="1024×768″/>
<classes>
<class name="BrowserStack.ExecuteFunctionalities"/>
</classes>
</test> <!- Test ->
<test name="Test on Edge">
<parameter name="browser" value="Edge"/>
<parameter name="browser_version" value="13.0″/>
<parameter name="os" value="Windows"/>
<parameter name="os_version" value="10″/>
<parameter name="resolution" value="1024×768″/>
<classes>
<class name="BrowserStack.ExecuteFunctionalities"/>
</classes>
</test> <!- Test ->
<test name="Test on Firefox">
<parameter name="browser" value="Firefox"/>
<parameter name="browser_version" value="44.0″/>
<parameter name="os" value="Windows"/>
<parameter name="os_version" value="10″/>
<parameter name="resolution" value="1024×768″/>
<classes>
<class name="BrowserStack.ExecuteFunctionalities"/>
</classes>
</test> <!- Test ->
</suite> <!- Suite ->

In this example, the TestNG annotation parameters have been used to get the value of the corresponding parameters and feed it to the capabilities object:

@org.testng.annotations.Parameters(value={"browser","browser_version","os","os_version","resolution"})

Now one can run the desired test automation suite on BrowserStack. Each test run has a unique session ID associated with it. Based on the session ID, all the details required for test execution will be fetched.

Each test execution has three bug logs generated.

  • One is a text log gives a textual representation of each process running in the background.
  • There is also a visual log that shows screenshots of the test being executed.
  • The video log gives a live recording of your test execution.

By migrating automated testing to a Selenium Cloud, the software development process becomes notably refined. Make things easier for the entire testing lifecycle by choosing a platform that is designed for developers. Deliver quality software with ease, and within competitive deadlines. Ship with confidence, every time.

Run Free Selenium Test using BrowserStack

Tags
Automation Testing Cross browser testing Selenium Selenium Webdriver

Featured Articles

Exception Handling in Selenium WebDriver

Setting up BrowserStack Automate

App & Browser Testing Made Easy

Seamlessly test across 20,000+ real devices with BrowserStack