What is RemoteWebDriver?

RemoteWebDriver connects to a server, send requests to that server and that server drives local browsers according to RemoteWebDriver requests. RemoteWebDriver 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 RemoteWebDriver 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.

Prerequisites for RemoteWebDriver

Nice to have: Before starting to read this post it is better to read previous selenium tutorials.

  1. http://www.swtestacademy.com/selenium-tutorial-java-junit/
  2. http://www.swtestacademy.com/selenium-webdriver-api/
  3. http://www.swtestacademy.com/selenium-webdriver-navigation/
  4. http://www.swtestacademy.com/selenium-webdriver-interrogation/
  5. http://www.swtestacademy.com/selenium-webdriver-manipulation/
  6. http://www.swtestacademy.com/selenium-webdriver-alerts/
  7. http://www.swtestacademy.com/selenium-webdriver-frames/
  8. http://www.swtestacademy.com/selenium-webdriver-windows/
  9. http://www.swtestacademy.com/selenium-webdriver-synchronization/
  10. http://www.swtestacademy.com/selenium-webdriver-cookies/
  11. http://www.swtestacademy.com/selenium-javascriptexecutor/
  12. http://www.swtestacademy.com/selenium-cross-browser-testing

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.


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


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.


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 on your SauceLabs dashboard page as shown below.



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.



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.


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.



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.


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.


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.


Test Code

Parallelized Class:

JUnitParallelTest Class:

Test Results While Test is Running:


Test Results After Tests Finished:


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


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.


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.


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 on testingbot cloud grid system. The way of connecting to the cloud servers is as same as for both providers. I show you a sample automation code that connects to the testingbot and runs the test on their server.

Test Code:

Test Result:

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



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]

Selenium Webdriver Tutorial Series