LambdaTestAutomation Testing ● Protractor Selenium Guide: Run Protractor Test Automation Scripts on Selenium Grid Cloud

Protractor Selenium Guide: Run Protractor Test Automation Scripts on Selenium Grid Cloud

LambdaTest Selenium Automation Grid is a cloud-based, scalable Selenium testing platform which enables you to run your automation scripts on 2000+ different browsers and operating systems. You can now run your JavaScript Selenium automated test cases on a scalable Selenium infrastructure that is running real browsers and real operating systems.

This post will help you in getting started with configuring and running your JavaScript-based automation test scripts on LambdaTest Selenium cloud platform using Protractor Selenium. This topic will help you to:

  • Run a sample Selenium WebDriver test using JavaScript on LambdaTest Automation.
  • To comprehend and configure Selenium test suite with respect to your capabilities.
  • Selecting the specific browsers to run your test on.
  • Explore advanced features of LambdaTest.
  • To run your test cases in parallel to reduce build times.
  • To test your locally hosted pages.

Prerequisites For Running Protractor Test Automation Scripts using Selenium

All the code samples in this documentation can be found in the Protractor LambdaTest Repository on GitHub. You can either download or clone the repository to quickly run your tests.

Before getting started with Automated Scripts using Selenium with Protractor test automation on LambdaTest, you need to:

  • The first step is to download and install node.js and node package manager or npm. Make sure you have nodejs v6 or newer. Click here to download.
  • Make sure to use the latest version of JavaScript.
  • If you have npm already installed, you may want to upgrade it to latest version. Here the code you can run in your terminal to upgrade npm.
  • Have AngularJS versions greater than 1.0.6/1.1.4.
  • Be familiar with Jasmine test framework.
  • Download Selenium JavaScript bindings from the official Selenium website.
  • Once you download the JavaScript bindings, extract the ZIP file which you’ve downloaded. After extracting the file, you need to add Selenium Java bindings which is a JAR file and all the dependent libraries to your classpath.
  • Download LambdaTest Tunnel binary file if you wish to test your locally hosted or privately hosted projects.

Getting Started With Protractor Test Automation with LambdaTest

Running Protractor Selenium test scripts on LambdaTest Selenium grid is as easy as changing a few lines of code. To start with, you would have to invoke Selenium remote webdriver instead of local browser webdriver. In addition, since we are using remote webdriver, we have to define which browser environment we want to run the test. We do that by passing browser environment details to LambdaTest Selenium grid via desired capabilities class. You can use LambdaTest Capabilities Generator to select & pass those browser environment specifications.

Let’s check a sample Protractor Selenium code running LambdaTest Selenium grid. This is a simple Protractor test automation script that tests a sample to-do list app. The code marks two list items as done, add a list item and then finally give the total number of pending items as output.

You can also find this code at our GitHub repository.

Below is the export.config file where we will be declaring the desired capabilities.

The Selenium Webdriver test would open a URL, mark the first two items in the list as done, add an item in the list, and return the total number of pending items. Your results would be displayed on the test console (or command-line interface if you are using terminal/cmd) and on LambdaTest dashboard. LambdaTest Dashboard will help you view all your text logs, screenshots and video recording for your entire Selenium tests.

Execute The Tests using Protractor Selenium

You would need to execute the below command in your terminal/cmd.

Going Into Details – What Is Protractor?

Protractor is an E2E(End-to-End) framework for testing an AngularJS application. Protractor test framework provides a sound evaluation of your web application by interacting with it just as an end user would, and executing tests through a real browser. It also offers Angular-specific strategies, so you could test Angular-specific elements without putting any extra effort from your end for the setup. Protractor is very convenient to use with continuous synchronization, the next steps in your test are automatically taken care of by the Protractor as soon as the pending tasks of the web page get completed. Protractor by default make use of Jasmine (Behavior-Driven JavaScript) test framework as the test interface.

If you are using Protractor test automation or planning to use Protractor selenium test automation, you can get started with LambdaTest Selenium grid quite easily. Integrating LambdaTest with Protractor will give your automation build capabilities to run on 2000+ different browsers, enabling you a wider test coverage. Coupled with Protractor’s inherent capabilities to manage tests, you get greater flexibility in running parallel test threads, boosting your build speed by multiple times.

In this post, we are going to dive into how you can integrate LambdaTest Selenium cloud grid in your Protractor Selenium testing suite. We are also going to touch upon how you can take advantage of LambdaTest parallel testing capabilities to speed up your test times and how you can leverage LambdaTest Tunnel feature to test your locally hosted or privately hosted pages even before launch.

Understanding & Configuring Protractor Selenium Desired Capabilities

As we said earlier the first step is to configure your test scripts to connect with LambdaTest Selenium automation gird. In the above mentioned JavaScript code, the first thing you would notice is the invoking of remote webdriver instead of the native browser webdrivers. So for example if you are planning to run on Firefox browser in your local machine, you would be using Firefox browser driver like this:

Since now you are performing the tests on LambdaTest’s Firefox browser, the code has to be modified a bit. To run the code on Firefox on LambdaTest Firefox browser, you’d need to add the following command to your existing JavaScript code:

In the JavaScript code, we are passing browser, browser version, and operating system information, along with LambdaTest Selenium grid capabilities via capabilities object.

Our Capabilities Generator will automatically generate the program, based on your provided input. For Instance, if you select the below configurations:

Operating System
Windows 8.1
Browser Version
Selenium Version

Then Capabilities Generator at LambdaTest will provide you with the below program:

The most important capabilities to understand here are ‘browserName’, ‘versions’, and ‘platform’. They define which browser environment you wish to run the test on. Rest of the capabilities are important in test management and debugging. We have an inbuilt capabilities generator tool as well that you use to generate capabilities code for your test suite.

You can also checkout our documentation on capabilities generator to understand more about individual capabilities.

Advanced LambdaTest Capabilities

In addition to default Selenium Grid capabilities, LambdaTest also has platform specific capabilities like a video recording of test runs, console logs of each test run, network logs of each test run, custom profiles for specific browsers, etc. Do check out our documentation on LambdaTest Advanced capabilities as well.

Test Locally Hosted Projects using Protractor Test Automation

LambdaTest allows you to test your locally hosted or privately hosted websites or web applications with the help of Secure Shell (SSH) Tunnel connection. LambdaTest Tunnel allows you to test your website or web-pages for cross browser compatibility even before they are live. You can connect your local server with LambdaTest’s Secure Cloud server using SSH tunnel and can perform cross browser testing on LambdaTest’s Selenium browser grid. You can also perform testing from different geo locations having different IP addresses and also test the applications secured with your organization’s firewall.

Follow our documentation on LambdaTest Tunnel to know it all. OS specific instructions to download and setup tunnel binary can be found at the following links.

Once you extract the file, you need to enter the following command in your command terminal. Make sure that you redirect the pointer to the same folder in which you’ve extracted the tunnel file.

So, let’s assume if your email ID is [email protected] and your user access key is 123asd321 then you’ll need to run the following command in command terminal.

Once you get a message that your ‘Secure connection established, you may start your tests now’ , you need to enter the following code in your JavaScript code block:

You can also add the capability using LambdaTest Capabilities Generator.

Tunnel Reference: For a full reference of all tunnel features we support, visit our tunnel page.

Mark Test As Pass Or Fail

While performing automation testing using Protractor Selenium on LambdaTest Selenium grid, it is imperative to flag an automation test as either pass or fails. This is completely dependent on your testing requirement with respect to the validation of expected behaviour. You can mark whether an automation test passed or failed by adding the below code fragment in your automation script:

Parallel Testing Using Protractor Test Automation

Parallel Testing is one of the most demanding features of LambdaTest Selenium Grid. By parallel testing, you can run more than one test case, simultaneously. This means that Parallel testing would allow you to execute numerous automation test cases altogether. So you execute a single test scenario across different browsers or could run different test scenarios across the same browser but with different browser versions. Wondering how many parallel test cases can you run? That depends entirely on the number of concurrent session under your opted plan.

For instance, if you have a bucket of 100 automated test cases, and the average time for execution of a single test is around 6 minutes. The time taken normally to completely execute all your test cases sequentially would be 600 minutes i.e. 10 hours. However, if you are opting for a plan which offers 2 concurrent sessions then you can perform 2 parallel test cases. This would divide your time in half as the total time taken through parallel testing with 2 concurrent sessions for the above scenario would be 300 minutes i.e. 5 hours. Similarly, if you have got 4 concurrent sessions with you then the time taken would be quarter with respect to sequential testing. This way you could fasten your release cycles as much as you want.

Protractor Test automation framework is really useful in running parallel tests. For instance, in our above example, you may notice that we are running our test on a single environment. If you want to cover multiple environments you would have to change the hard code every time. Or you would have to use arrays, or multi-threading or something similar.

With LambdaTest, you can pace up your test build activities by performing parallel automation testing using Protractor Selenium with JavaScript. Boost quality assurance of your product by performing extensive and fast-paced automated cross browser testing process with LambdaTest parallel testing.

Checkout the same code below to understand it better. You can also find it at our github page here.

To perform parallel automated testing using LambdaTest Automation in JavaScript using Protractor Selenium.

Parallel Testing Example

Here is parallel conf which executes the same tests in parallel.

If you notice, with simple annotations and parameters, you can now run your test suite on multiple browsers every time, without changing the browsers parameters in code files every time.


To prevent over-exploitation of the platform we have added a capacity constraint on the number of tests that can be queued at our platform. Your maximum queue capacity will be dependent upon the number of concurrent sessions your LambdaTest account is eligible for. Below formula will help you calculate the maximum capacity for your queue.

Maximum Queuing Capacity

Maximum number of parallel tests that can be queued = n + 150

Here, n = number of concurrent sessions.

For example, if you have opted for pricing where you can avail up to 10 concurrent sessions. Then the maximum number of parallel test cases that can be queued will be equal to 10 + 150 i.e. 160 parallel test cases. Queuing allows you to manage your test pipeline in a hassle-free manner. LambdaTest would automatically schedule and execute test cases for you.

LambdaTest Queuing Policy

Here you can get more information about LambdaTest Queuing Policy.

Queuing Timeout

There is also a limit on how long a test case can stay in the queue. If your test case stays in the queue for more than 15 minutes, the test case would be timed out and would not be executed.