Run selenium test on cloud


Running test automation on the cloud is pretty much similar to running the test over the selenium grid as both require Remote WebDriver Capabilities to be set.


Cloud is a collection of hardware and software resources kept at the server, which can be used by a user on a need basis. Users can take a subscription and use the hardware or software resources located somewhere at a remote server which we call a cloud. In this way, the user must not have to procure the hardware resource or need to purchase the software and install it on his local machine. The user just pays for the subscription and makes use of the hardware resources or software resources.


A very good example is BrowserStack. Browserstack is a SAAS/PAAS that provides real-time access to numerous hardware and software resources like mobile phones from android to iPhone, Operating systems, browsers, etc. A user can pay for the subscription and use these remote resources, perform testing on these resources, run their automation scripts, and so on. Unlike good old traditional days where a company has to procure all the physical devices and purchase licenses of the software which are needed and then perform operations on them. But with the advent of cloud infrastructure, the overhead of procurement of physical devices, hardware, and acquiring the licenses have totally gone. It is just like going to a restaurant, order as per your liking, consume the service, and go back.



How to run selenium test on browser stack


Assuming you have written your test automation on your local machine and want to run these automation tests on a browser that you do not have. Or to a mobile device that you do not have. Instead of installing a browser on your local machine or procuring the device, you can purchase the subscription of BrowserStack and use the browser or device remotely. It is more or less similar to the selenium grid.

BrowserStack is a subscription-based SAAS/PAAS but thanks to its free trial, an individual can access the real device for few hours. You can signup and opt for a free trial in which you can use it for free for limited hours.

Sign up to browser stack. Select a free trial. Select the OS, browser, version, device, etc. as per your need. Now next step is to configure your test. In the configuration step, you have to select the technology in which you want to automate or have automated your tests. You have to select anyone from JAVA, NODE, PYTHON, C#, PHP, PERL, RUBY. Once you select the language, the browser stack provides you the code snippet as per the language you have chosen. These code snippets are desired capabilities as per the OS and browser you have chosen, and important variables and their values like user name, automate key, URL. Browser stack assigns you a unique username and automation key which you have to pass in your automation test so that BrowserStack can identify you when you execute your test automation on BrowserStack.

desired capabilities for executing test automation on cloud

Above are the code snippets you have to copy into your automation codebase. These are the desired capabilities as per the OS and browser you have chosen and user name, automation key, and URL. In the below image, the username, and automation key is passed in the URL.

desired capabilities for executing test automation on cloud

Now execute your automation. You can see the execution happening in the cloud server by visiting the browser stack's dashboard.

test executing on cloud

You can also playback the automation and see how it was executed on the cloud server. Click on the build. You can see the console log, and a screen with a play option.

play back execution on cloud

In this way, you can execute your test automation on the cloud. Also, check the selenium grid tutorial Selenium Grid