Selenium 13: Test Automation in the Cloud with RemoteWebdriver


What is RemoteWebDriver?

Remote WebDriver connects to a server, send requests to that server and that server drives local browsers according to Remote WebDriver requests. Remote WebDriver needs to be configured, then it can run a test on external machines. It composed of with a client and a server. The client is our webdriver test and the server is a Java servlet. The server will always run on the machine with the browser you want to test.

We configure Remote WebDriver with DesiredCapabilities (it configures browser type, version, platform, etc.) and external server URL. Then, we can run our tests on the server which we configured for RemoteWebDriver.

We can set up Selenium Server on our local computer or we can use cloud grid system providers such as SauceLabs, Browserstack or TestingBot, etc. This kind of companies provides extensive grid on their servers. You can find all OS and all browser versions. In this post, I will explain how to test with those services. In order to test on those provider’s servers, we need to go their sites and register for a free plan.

Cloud Testing with SauceLabs

SauceLabs is a grid in the cloud. We can run our tests on their cloud with different browsers and operating systems. You can also do manual testing. In order to do these, first we should go saucelabs.com and register for free as shown below.

webdriver

Then, when you log in SauceLabs, you will see below screen.

saucelabs

Before start coding, we should do prerequisites. These are:

  • I assumed that you have got JAVA JDK, Selenium Webdriver as described in this post.
  • Then, we should install the Java Helper Library, which will automatically update your Sauce Labs dashboard with information like whether tests have passed or failed, output the Sauce Session ID to stdout for parsing by the Sauce Jenkins and Bamboo plugins, and which provides a saucelabs.common.SauceOnDemandAuthentication class, which handles obtaining the Sauce OnDemand username and access key from environment variables or the filesystem.
    [1] In order to do this, you should simply add below lines in your pom.xml as shown below.

saucelabs

How to get Access Key?

Sauce Labs accounts are protected by a username, a password and an access key. We use our username and password to access Sauce Labs’ site, and we use our username and access key to allow our tests to access SuaceLabs’s Selenium servers. [2]

You can see your access key in your SauceLabs dashboard page as shown below.

saucelabs

saucelabs

When you get your access key, we can connect SauceLabs servers and run Selenium Webdriver tests. A sample test code is shown below.

After test completed, you will check its result also in your SauceLabs dashboard.

saucelabs

saucelabs

Cloud Testing with BrowserStack

BrowserStack is another option run your test in the cloud. First we have to visit https://www.browserstack.com/ and click “FREE TRIAL” and register for free.

browserstack

When you register BrowserStack (BS), you need to click “Automate” and then “Settings” and go to the end of that page to reach your automation access key information as shown below.

browserstack

browserstack

When we got the username and access key info we can write our test code similar to SauceLabs’s test code as shown below.

After test finished, you can check results, video, status and logs of your test in BrowserStack’s dashboard page as shown below.

browserstack

On Dashboard page when you go Docs section, you will find extensive information for each programming languages. I highly recommend you to check this section.

browserstack

Parallel Test Execution in the Cloud

One of the most important point testing in the cloud is parallel testing. It speeds up your testing time pretty much. In order to handle parallel test execution, you can check Docs section. BrowserStack presents how to do parallel test execution documentation for both JUnit and TestNG frameworks. In automation projects, I generally prefer to use JUnit so in this post, I will make an example with JUnit framework. However, you can find also TestNG code sample in Docs section.

You can get driver capabilities in https://www.browserstack.com/automate/java link’s “Setting your operating system, browser, and screen resolution” section. It is very very useful when you configure DesiredCapabilities. It is shown below.

browserstack

Test Code

Parallelized Class:

JUnitParallelTest Class:

Test Results While Test is Running:

browserstack

Test Results After Tests Finished:

browserstack

When you click any test result, you can reach its video and the details as shown below.

browserstack-4

Cloud Testing with TestingBot

TestingBot provides easy cross-browser testing in the cloud keeping your websites bug-free. They provide a service to easily test our websites in different browsers either automatically or manually. You can find its all features on their website. [4]

In order to test with TestingBot, we should go their website and click “START FREE TRIAL” button. It means we can try their system for free. When you register, you will see their dashboard page as shown below.

testingbot

In order to run our automation test in testingbot servers, we need to get our “Client key” and “Client secret”. We will connect their servers with this information. You can get this information by clicking “Account” link.

testing-bot-2

Then, go to Dashboard page again and click your test automation programming language to see the instructions. In our case, we will go with JAVA. When I clicked to JAVA logo, I reached https://testingbot.com/support/getting-started/java.html page. In this page, you can find all information about how to run your automation test in testingbot cloud grid system. The way of connecting to the cloud servers is as same as for the both providers. I show you a sample automation code that connects to the testingbot and runs the test in their server.

Test Code:

Test Result:

You can see the result under “Automated tests” tab.

testingbot

References

https://wiki.saucelabs.com/display/DOCS/Java+Test+Setup+with+Sauce+Labs+Example [1]

https://support.saucelabs.com/customer/en/portal/articles/2092509-protecting-your-access-key [2]

https://www.browserstack.com/automate/java [3]

https://testingbot.com/ [4]

https://testingbot.com/support/getting-started/java.html [5]

javafx

Database Operations in JavaFX

By Onur Baskirt / Apr 1, 2016 / 56 Comments
Before started this section, please check the first article and learn How to Start JAVAFX! http://www.swtestacademy.com/getting-started-with-javafx/ At first, part of JavaFX tutorial series, we created a sample JavaFX project, designed the draft version of the UI and set up an...
rest assured

REST API Testing with Rest Assured

By Onur Baskirt / Mar 8, 2016 / 32 Comments
Outline In this post, I will explain what is API and API testing, what is the difference between SOAP and REST services, and how to test REST APIs with Rest Assured Library. What is API? API stands for Application Programming...
extentreports

How to Write Effective CSS Locators

By Onur Baskirt / Oct 1, 2017 / 0 Comments
Hi all, in this tutorial, I will describe you how to write effective CSS locators to interrogate web elements for your automation projects. As a rule of thumb, your interrogation strategy should be in below order: First try to use...
extentreports

Selenium-11: Execute JavaScript with JavascriptExecutor

By Onur Baskirt / Jan 27, 2016 / 15 Comments
Outline Sometimes we cannot handle some conditions or problems with Webdriver, web controls don't react well against selenium commands. In this kind of situations, we use Javascript. It is useful for custom synchronizations, hide or show the web elements, change...
javafx

Getting Started with JavaFX

By Onur Baskirt / Mar 25, 2016 / 0 Comments
When I started to work in my current position, one of my task is to do manual operations for campaign products  every week. After the second week, I thought that I have to automate this task using a GUI based...
extentreports

How to Write Smart XPath Locators

By Onur Baskirt / Sep 24, 2017 / 4 Comments
Hi all, in this tutorial, I will describe you how to write smart and non-brittle XPath locators. When we write our test scripts, we generally prefer to use id, name, class, etc. these kinds of locators. However, sometimes we could not...
extentreports

Selenium-1: Quick Start to Automation with Selenium WebDriver & JAVA & JUnit & Maven & IntelliJ

By Onur Baskirt / Sep 8, 2015 / 26 Comments
Outline Selenium Webdriver is the most popular open source web test automation framework across wide range of browsers and platforms. In this tutorial you will learn how to do web test automation with Selenium Webdriver and the related tools. Audience...
page object model

Page Object Model with C#

By Ege Aksoz / Jun 18, 2017 / 8 Comments
In the previous tutorial, we’ve taken the initial steps and entered the world of automated testing. We also wrote our first automated test. From this point on, since we are not just going to write one test, we need to...
extentreports

How to Select a Date From DatePicker Using Selenium

By Onur Baskirt / Aug 13, 2016 / 6 Comments
When you need to automate a airway, hotel, or similar websites you need to deal with Datepickers and some times it is a little bit cumbersome to select a specific date on the Datepicker or calendar.  In this post, I...
extentreports

Selenium Webdriver Performance testing with Jmeter and Selenium Grid

By Ozgur Kaya / Aug 9, 2016 / 2 Comments
In this post, we will complete Selenium Webdriver Performance testing scenario using Jmeter and Selenium Grid. 1- Install Java 7 or later If necessary https://java.com/tr/download/ 2- Download latest Jmeter version 3.0 or higher. http://jmeter.apache.org/download_jmeter.cgi 3- Download Jmeter PluginsManager JAR file and...
By | 2017-01-13T21:33:43+00:00 February 29th, 2016|Selenium, Test Automation, Web Automation|4 Comments

Share This Story, Choose Your Platform!

About the Author:

Onur Baskirt
Onur Baskirt is a senior IT professional with 10+ years of experience. He worked at Bahçesehir University, ST Microelectronics, Huawei and Ericsson as research assistant, design verification engineer and software test leader. Also, he worked as software test leader and software operations manager at Turkey's biggest technology retailer, Teknosa. Now, he is working as Head of Software Testing and Manager of two Development Teams at Kariyer.net. His current research areas are technical software testing, programming, and computer science. Formerly, he has several research works and papers on digital chip design & verification. His hobbies are sport, dancing, traveling, and nutrition. You can find detailed information about him on his linked-in page.

4 Comments

  1. Michael February 29, 2016 at 5:08 pm - Reply

    Great writeup!

  2. Aravind March 3, 2016 at 11:06 am - Reply

    Does SauceLabs support appium for IOS? Can i run appium tests in parallel in cloud?

Leave A Comment