LambdaTest Community

Find answers, support, and inspiration from other users

LambdaTest Community

How can I perform Automated cross browser testing with Protractor & Selenium?

Can anyone please provide me some valid guidance on how can I perform Automated cross browser testing with Protractor & Selenium.

Up Vote Down Vote 0 Votes
Posted 4 months ago


Getting Started With Cross Browser Automation Testing With Protractor and Selenium

Here are the prerequisite required for performing cross browser automation testing with Protractor and Selenium on Windows:

  • Node.js
  • Install protractor using npm
  • Update webdriver manager and start up a server
  • Visual Studio Code

Setting Up Automation Environment For Testing With Protractor And Selenium In Windows

This section has detailed steps explaining how to setup environment for performing end to end cross browser automation testing with Protractor and Selenium through Windows.

Step 1: Installation of Node.js

You need to install npm for Node.js.

What is npm?

npm is a free to use, package manager for javascript development which helps you to download all public software packages

What is package manager

A package in node.js contains group of files that you need for a module. Module is nothing it’s javascript libraries that can be included in your project.

To install Node.js, click here.

Once you are done downloading the installer, run it as administrator.

Click on ‘Next’ button in Node.js setup window to proceed further.

Step 2: Installation of Protractor using npm

To download a package, open a command prompt and supply the following command

  • npm install –g protractor install command is for download the package

-g stands for global which means any command to operate in global mode.

Step 3: Update WebDriver Manager and Start Up A Server

To update webdriver manager, supply the following commands

  • webdriver-manager update

Step 4: Installation of Visual Studio Code

Writing Sample Code for Automation Testing With Protractor and Selenium

Now, we will have a look at a sample Javascript code for automation testing with Protractor and Selenium, and execute the test in local instance meaning execute the test that run on your browser installed in your machine.

To run protractor test for end to end automation, you must need two files:

  • Specs
  • Config

Specs: Specs is actual test suites that have more than on test cases designed in Javascript using Jasmine framework.

What is Jasmine Framework?

Jasmine is a BDD(Behaviour Driven Deployment) testing framework for Javascript. This framework helps you to write clean and better readability of code. To know more about Jasmine Framework, please visit here.

Executing Single Instance For Automation Testing With Protractor and Selenium WebDriver(Local)

Here is the simple example config file and how to write basic code in Protractor using Jasmine Framework.


exports.config = {
 seleniumAddress: 'http://localhost:4444/wd/hub',
 specs: ['lambdatest_spec.js'],
 multiCapabilities: [{
 'browserName': 'chrome',
 'browserName': 'firefox'

In the above snapshot shows the syntax of how to define config file to execute browser automation with Protractor and Selenium.

  • seleniumAddress: Protractor make use to Selenium Grid to run your test in specified browser.

  • specs: specs indicates test suite that you can mention in one or more spec files to run multiple tests.

  • Capabilities: This is the place where you can capability setting for your test configuration for eg., browser version, platform etc., in case no capabilities is provided then by default, it takes chrome browser in your machine.

describe('To verify Angular and non Angular application test', () => {

it('To verify page title of Lambdattest', () => {

browser.get("Free Cross Browser Testing Tool on Cloud | Selenium Automation Testing");

element(by.css('p.home-btn > a.home-cta')).click();

expect(browser.getTitle()).toEqual('Signup - LambdaTest App | Free Cross Browser Testing Tool');



We will see clear explanation of what is the above code indicating.

describe –> describe is the keyword from Jasmine to write syntax for test suites. This is definition of collection of test cases in your script file.

it –> is the keyword for test cases to meet specific condition. There can be more than one “it” added under describe in Jasmine framework.

In the above code, we launch the browser, navigate to sign up page, see the title gets matched and pass the results.

To run your test:

In Visual Studio Code: Go to View Menu-> Click “Terminal” and supply the following command

Syntax: To run your test suites protractor followed by config file name.

Note: Before run your test, please make to run selenium Grid by supply the following commands:

  • webdriver-manager start

After executing the above test, observed the following failures which is expected

The above screenshot indicates the website is not developed using AngularJS component. This is best real time examples to realize how Protractor works while launching browser. As mentioned in “Advantages” topic in above, the Protractor basically tries to connect with Angular JS framework while launching application. The moment Protractor identified and realized it’s not an AngularJS component, it recommended us to turn off waiting for Angular.


Up Vote Down Vote 0 Votes
Posted 3 months ago