Protractor interview questions

Protractor interview questions
Download Protractor interview questions PDF

Below are the list of Best Protractor interview questions and Answers

Protractor is an end to end testing framework for AngularJs Applications. It is built on top of WebDriverJs protocol which internally uses native events and browser-specific drivers to interact with our application. 

  • It uses the simple syntax for writing test cases.
  • Have angular-specific locators like ng-model, ng-bind, etc.
  • Supports behavior-driven development tools like Jasmine/Mocha 
  • Easily integrated with Jenkins/Browser, Stack/Grunt.
  • Support all latest browsers like Firefox, Chrome, Safari, Internet explorer.

You can use the following commands to install Protractor on windows:

Use npm to install Protractor globally with:
npm install -g protractor

You can cancel Alert in Protractor by using dismiss() as follows:

The dismiss() method is used to cancel the alert for handling alerts in Selenium. It is functional for all alert types: prompt, alert, and confirmation dialogue box.

It activates by clicking on the “X” button in the prompt. 

You can accept Alert in Protractor by using accept() as follows:

The accept() method is used to accept an alert and continue with the webpage operation. It can be utilized for all JavaScript alert types. An alert command can be executed by using the variable for handling alerts in Selenium:

var myAlert = browser.switchTo().alert();
Click on the 'OK' button will confirm the action

Few locators available in Protractor are as follows:

  1. by.className
  3. by.CSS
  4. by.linkText
  6. by.partialLinkText
  7. by.tagName
  8. by.xpath

WebbDriver click() simulates real user interaction with the UI whereas JavaScript click() executes JavaScript in the currently selected frame or window.

You can use the following code to set the default window size in Protractor/WebdriverJs:

browser.executeScript('window.moveTo(0,0);' + 'window.resizeTo(screen.width, screen.height);');

You can get the current URL using protractor by using browser.getCurrentUrl() as follows:


Mouse actions are the demonstration of mouse activities (such as hover, clicking, drag, and drop) that can be easily simulated in Selenium Protractor with the predefined methods for mouse movement, clicking, and others.

Different mouse actions that can be performed using protractor are as follows:

  1. mouseMove()
  2. dragAndDrop( source , target )
  3. click()
  4. doubleClick()
  5. mouseUp()
  6. mouseDown()
  7. contextClick()
  8. clickAndHold()
  9. dragAndDropBy(source, xOffset, yOffset)
  10. moveByOffset(xOffset, yOffset)
  11. moveToElement(toElement)
  12. release()
  13. mouseMove()
  14. mouseHover()

Major differences between Protractor and Selenium are as follows:

Selenium WebDriverProtractor
You can automate the web applications using the selenium WebDriver with Java or any programming language of choice.Prefer Protractor when you are not comfortable with handling the ajax and angular waits using fluent wait in Selenium.
The languages supported by Selenium are Java, Python Kotlin, C, C#, PHP.All js related languages are supported by Protractor. Ex: TypeScript and JavaScript.
Supports many frameworks of unit testing, such as TestNg and Junit.Protractor works well with Jasmine and Mocha frameworks.
You need a lesser number of code lines for testing with Selenium.Code length is longer when you use Protractor because all of the fetch operation return promises, so you have to solve the promises first.
Selenium’s performance is faster for a non-Angular web application.When working with Angular applications, the protractor offers faster performance.
It is open-source software.It is also open-source software.
Enough options for locators.Lesser option for locators.
Debugging is easy owing to Java-based design.Debugging needs expertise and time-consuming.
Technical skills mandatory to work with this tool are Java and TestNG.One needs to know JavaScript and Node.js to work with Protractor.
Licensed under Eclipse.Licensed under Webstorm7.0.
The framework is proven and widely used.The framework is budding and harder comparatively.
Compatible with Windows and Linux.This is also compatible with Windows and Linux.
Works well with Angular pages too; however, page synchronization issues may crop up.Designed specifically for Angular pages and works with non-angular too without any issues.
Proven, widely used for automation, well-extended support, and stable API.New entrée in the market and needs the expertise to work with.
You can work in popular programming languages such as Python, Ruby, Java, Perl, C, and C##.Available only for JavaScript.
Offers comprehensive support for all sorts of testing needs for web applications.This is just a wrapper developed over WebDriver JS. No new verticals for browser automation are developed as such.
Cannot trace and work with angular directives in a code.Rich in angular specific locator strategy and can work comfortably with locators.

Yeoman is a scaffolding system that allows you to rapidly create any kind of application. It gets you to start on the new projects and streamline the maintenance of the existing projects. You can create a project with yeoman in any language.

Yeoman is also used to bootstrap new services, create modules or packaged, promote new projects, and enforce standards & best practices.

Grunt is a JavaScript task runner that lets you do less work for performing repetitive tasks such as minification, compilation, unit testing, compilation, and linting. It makes doing these jobs easier. Grunt provides you with many plugins to automate these jobs with less effort. Some of the available plugins with the Grunt are CoffeeScript, handlebars, jade, JS Hint, less, sass, etc.

Jasmine is a development framework used for testing JavaScript code. It is a behavior-driven framework that does not depend upon any other frameworks. Jasmine doesn’t require DOM and has clean syntax so you can write tests easily. It has low overhead with no external dependencies so it is fast. It also runs on your browser and you can test with Node JS.

Mocha is a JavaScript testing framework that runs on your browser with Node JS. With this, you can easily create an asynchronous test. The tests from the Mocha can run serially with high flexibility for accurate reporting. It is an open-source framework that is maintained by volunteers.

Protractor support Jasmine and Mocha BDD test frameworks.

A SPA application is a web app load a single HTML page and dynamically update that page as the user interacts with the app.SPA using ajax and HTML5 to create fluid and responsive Web apps, without constant page reloads.