300+ TOP Protractor Automation Interview Questions [UPDATED]

  1. 1. What Is Protractor?

    Protractor is an end-to-end test framework, designed for Angular and Angular JS applications. Protractor is a node.js port of the webdriverio, which is the JavaScript implementation of Selenium framework.

  2. 2. Why Protractor And Not Selenium With Any Other Language Like Java?

    It totally depends on the choice of the team and the ease of the implementation for the QA team. There is a no hard and fast rule that you should use Protractor when the UI is built with Angular or Angular JS.

    The real benefit for using Protractor narrow down to the two major points that I think should be taken into consideration while deciding whether or not to use Protractor

    Protractor handles the $http or $timeout synchronization issues arising out of Angular/Angular JS very well.

    Since Angular/Angular JS code is written in JavaScript/TypeScript, and Protractor supports both these languages, so there is sync between the devs and QA when using a single operating language for FE as well as the test framework.


  3. Testing Tools Interview Questions

  4. 3. What Are The Locators In Protractor?

    Apart from the basic locator mechanism that Selenium implementation gives , Protractor has some Angular JS specific locators.

    1. By Binding
    2. By Model
    3. By Button Text
    4. By Exact Binding
    5. By Partial Button Text
    6. By Repeater
    7. By Exact Repeater
    8. By CSS Containing Text
    9. By Options
    10. By deep Css
    11. Custom Selectors
  5. 4. What Are Element Finder And Element Array Finder?

    The Protractor documentation mentions the distinction in most simple way:–

    Element Finder:

    • The Element Finder simply represents a single element of an ElementArrayFinder (and is more like a convenience object). As a result, anything that can be done with an Element Finder can also be done using an ElementArrayFinder.
    • The Element Finder can be treated as a Web Element for most purposes; in particular, you may perform actions (i.e. click, get Text) on them as you would a Web Element. Once an action is performed on an Element Finder, the latest result from the chain can be accessed using the then method. Unlike a Web Element, an Element Finder will wait for angular to settle before performing finds or actions.

    Element Array Finder:

    • ElementArrayFinder is used for operations on an array of elements (as opposed to a single element).
    • The ElementArrayFinder is used to set up a chain of conditions that identify an array of elements. In particular, you can call all (locator) and filter (filterFn) to return a new ElementArrayFinder modified by the conditions, and you can call get(index) to return a single Element Finder at position ‘index’.
    • Similar to jquery, ElementArrayFinder will search all branches of the DOM to find the elements that satisfy the conditions (i.e. all, filter, get). However, an ElementArrayFinder will not actually retrieve the elements until an action is called, which means it can be set up in helper files (i.e. page objects) before the page is available, and reused as the page changes.
    • SO, basically, if you’ve ever worked with Selenium in the past, you’d recognise that it is nothing but the difference between Find Element and Find Elements.

  6. Testing Tools Tutorial

  7. 5. Can I Use Protractor For Non Angularjs Apps?

    Absolutely Yes. Protractor can be used for testing non Angularjs or non Angular apps.


  8. Agile Testing Interview Questions

  9. 6. What Are Protractor, Jasmine, And Mocha? How Can We Use Them?

    Protractor, as described above, is the node.js implementation of webdriver.io, which is in turn the .js implementation of Selenium. So in short, it is in fact, the Selenium implementation in .js optimised for Angular or Angular JS applications. It is the overall framework that provides with the baseline methods and functions to interact with the HTML/DOM elements on a web page.

    Jasmine
    – It is a test framework, like Junit (Java) and Unit Test (Python). It comes bundled with a lot of assertions and it is the default framework when working with Protractor. Jasmine supports BDD- styled tests using the describe- it syntax.

    Mocha
    – Mocha is a test runner. Many people confuse it with Jasmine as a test framework. It is not a framework. Although it gives you a lot of features like a Test frameworks like hooks, the describe-it syntax, but it can not add assertions and other key unit testing components. You will always need it to pair with something like chai or chai-as-promised.

  10. 7. How To Assert Something In Protractor?

    It depends on the assertion framework you’re using. In general, most of the e2e implementation done is based out of the default Jasmine 2.0, which provides the assertion in this format

    expect (something).toEqual (someotherthing).

    In case you’re using Mocha with a Chai as the assertion engine, you can use either of the three assertion types provided by Chai as

    • expect (something).to.equal (someotherthing)
    • something.should.equal (someotherthing)
    • assert.equal (something, someotherthing)

  11. Agile Testing Tutorial
    Selenium Interview Questions

  12. 8. Explain How You Can Set Up Protractor In Your Project?

    It is very simple to set up Protractor in your project. Protractor is a node.js program, so it can be easily installed via any package manager that supports node.js installation – both npm and yarn are the go-to package managers in most scenarios.

    Your system set up should have node.js runtime installed. Since npm comes by default with node.js, so you can use it or you can download and use yarn.

    In case of npm, installing Protractor is just a matter of running this simple command – for node v.8.0+

    npm i -g protractor or

    npm install -g protractor

    This command installs both Protractor and Web driver-Manager. Once Protractor is installed, you can check the version using

    Protractor -version

    Now, once Protractor is installed, you’ll not be ready for running the tests yet. You need the Chrome Driver or the Gecko Driver binaries for establishing connection with the browser.

    To achieve this, you’ll need to run

    Web driver-manager update

    This will install the web driver-server along with the browser dependencies.

    Once this is done, you’ll have Protractor set-up in your project. Now the next step is to write the test cases using the spec.js file and set up the Protractor configuration using the conf.js file.

  13. 9. Can You Walk Me Through A Simple Set Up Of Protractor?

    This is similar or another way of asking the same question answered above. Just walk through how to install Protractor in the project.


  14. Automation Testing Interview Questions

  15. 10. I Do Not Want To Start The Selenium Server Every Time. How Can I Overcome This?

    In order to not have to do this, you need to set the direct Connect flag to true in your conf.js file.


  16. Selenium Tutorial

  17. 11. What Does Ignore Synchronization Do?

    In Protractor, while running tests, this is a common problem, when the Protractor execution starts, but the Angular code is still trying to synchronise the $http or $timeout requests. Setting the browser.ignoreSynchronization to true means that we’re telling Protractor to not wait for the Angular promises to be resolved.


  18. Test Cases Interview Questions

  19. 12. What Frameworks Can Be Used With Protractor?

    Protractor can be used with a variety of frameworks. By default, Protractor comes bundled with Jasmine 2.0. You can also pair Protractor to use mocha, Cucumber JS, Serenity.

    If you want to use it with any other custom frameworks, then you can do that also.


  20. Testing Tools Interview Questions

  21. 13. How Can You Do Reporting In Protractor?

    Protractor doesn’t come bundled with any reporting tool. However based on the framework that you’re using, you can use a lot of reporters. For eg, you can use Allure with Jasmine 2.0 with Protractor, Mochawesome when using with Mocha and Cucumber specific reporters when working with Cucumber.


  22. Unittest Framework Tutorial

  23. 14. Can I Use Protractor With Typescript?

    Absolutely Yes. You can use TypeScript with Protractor. There is a whole section in Protractor docs dedicated to configuration and examples.  You can also use this example to get configured.

  24. 15. How Can I Add Custom Locator For Protractor?

    You can use the add Locator method to do the same. Please go through this sample example to understand how it can be done.


  25. Unittest Framework Interview Questions

  26. 16. What Is The Default Time For A Protractor With Jasmine Spec To Fail And Can I Change It?

    By default, any spec in Protractor will fail after a period of 30 seconds because that is the default time out for a Jasmine spec to fail.

    Yes, this timeout period can be configured to be increased or decreased.  In order to change the default timeout period for all specs, you need to add

    JasmineNodeOpts: {defaultTimeoutInterval: timeout in millis}

    To you conf.js file, where the second option is the time period that you want to set.

    Note:
    In case you’re using with Mocha, this can be set using mocha. Opts file.

  27. 17. How To Run Multiple Specs In Protractor?

    In order to run multiple spec files in Protractor, you just need to mention them in the spec flag in an array.

    For eg, let’s say I have two different spec files test1_spec.js and test2_spec.js, so I can do this

    Specs: [‘. /test/test1_spec.js’,’./test/test2_spec.js’]

    This will make Protractor run these multiple spec files.


  28. Performance Testing Interview Questions

  29. 18. Select A Checkbox Using Protractor?

    We need to follow few steps to make sure that element is selected or not, Normally when we have this kind of scenarios what we do is, we will use click() method to select the check box. After this we might move on to next step of scenario.

    Sometimes not selecting will help you; you got to make sure that the checkbox is selected. To verify it we need to use the is Selected () method and get check whether it is really selected.


  30. Agile Testing Interview Questions

  31. 19. What Is The Good Reporter In Market For Protractor?

    As of now, we can say chercher-tech-jasmine-reporter is more suitable report for the protractor and Jasmine combination.

  32. 20. What Is Group Index In Xpath?

    Group index is nothing but writing the XPath as sequence. For example, XPath provides numbers from 1, 2, 3… For element under every parent.

    When we use index we might get end up having multiple elements when we wanted a particular element.

    In such cases the Group index will be more helpful to the user. Now the Group index numbers the element from 1…, even though element under different parent.

    The index numbers will never be repeated.


  33. Test Plan Interview Questions

  34. 21. How Do You Handle A Text Area Element?

    Textarea doesn’t have much difference from text bar, so we can handle it like normal text box/text bar element.

  35. 22. How To Handle The Installation In Protractor (select Has Maven For Installations)?

    It is not just for maven; t is for all node js application. We can use the package.json file as installation files, when we specify a version in package.json then node will install the specified version in our system. 

    Package.json not just stops with installation it also perform operation like compiling, running the tests.

  36. 23. How Can We Find All The Links On A Web Page?

    All the links are formed using anchor tag ‘a’ and all links will have href attribute with URL value. So by locating elements of tag Name ‘a’ we can find all the links on a webpage.


  37. Test Automation Framework Interview Questions

  38. 24. How To Verify Tool Tip Text Using Protractor?

    Web elements have an attribute of type ‘title’. By fetching the value of ‘title’ attribute we can verify the tooltip text in protractor.


  39. Selenium Interview Questions

  40. 25. What Are The Different Mouse Actions That Can Be Performed?

    • Click (element)
    • Double Click (element)
    • Context Click (element)
    • MouseDown (element)
    • MouseUp (element)
    • MouseMove (element)
    • MouseMove (element, long xOffset, long yOffset)
    • Drag And Drop ()
  41. 26. Write A Code To Wait For An Alert To Appear?

    Waiting for an alert to appear on a page can be performed using explicit wait in protractor.

    Browser. Wait (ExpectedConditions.alertIsPresent (), 30000)

  42. 27. Write A Code To Wait For A Particular Element To Be Visible On A Page Using Protractor?

    Visibility means that the element is not only displayed but also has a height and width that is greater than 0. You can use visibility of function to check the visibility of the element

    Let EC = Expected Conditions;

    Let condition = EC.visibilityOf (element (by.id (“hidden”)))

    Browser. Wait (condition, 30000)


  43. Automation Testing Interview Questions

  44. 28. Can Protractor Handle Windows Based Pop Up?

    Protractor is a web automation testing tool which supports only web application testing. Therefore, windows pop up cannot be handled using Protractor.

  45. 29. Return Javascript Execution Result?

    We need to return from your javascript snippet to return a value, so: browser.executeScript (“document. title”); will return null, but: browser.executeScript (“return document. title”); will return the title of the document.

  46. 30. What Are The Advantages Of Automation Framework In Protractor?

    • Re-usability of code
    • Maximum coverage
    • Recovery scenario
    • Low cost maintenance
    • Minimal manual intervention
    • Easy Reporting
    • Logging for debugging
    • Easy Coding
  47. 31. What Is An Xpath?

    XPath or XML path is a query language for selecting nodes from XML documents. XPath is one of the locators supported by Protractor. 

    Selenium web driver supports only XPath 1.0, selenium does not support XPath 2.0, 3.0

  48. 32. What Is The Order Of Fastest Browser Implementation For Protractor?

    HTML Unit Driver is the fastest browser implementation as it does not involves interaction with a browser; this is followed by Firefox driver and then IE driver which is slower than FF driver and runs only on Windows.

  49. 33. What Are The Prerequisites To Run Protractor?

    JDK, Web Driver (selenium standalone jar file), browser, application to be tested.


  50. Test Cases Interview Questions

  51. 34. What Are The Web Pages Elements In Web Applications?

    Link Button Image, Image Link, Image Button Text box Edit Box Text Area Check box Radio Button Drop down box List box Combo box Web table /HTML table Frame.

  52. 35. What Is The Difference Between Browsers. Close () And Browser. Quit () Command?

    Close ():
    Protractor close () method closes the web browser window that the user is currently working on or we can also say the window that is being currently accessed by the Web Driver. The command neither requires any parameter nor does is return any value.

    Quite ():
    Unlike close () method, quit() method closes down all the windows that the program has opened. Same as close () method, the command neither requires any parameter nor does is return any value.

  53. 36. What Is Element Finder?

    The Element Finder is nothing but elements present in the web page, we will get this as result of element (by. locator (“locator value”))

    Element Finder can be used to build a chain of locators that is used to find an element.

    An Element Finder does not actually attempt to find the element until an action is called, which means they can be set up in helper files before the page is available.


  54. Unittest Framework Interview Questions

  55. 37. Test Case Failed Saying “element Not Visible”, But When Analyzed Manually Element Is Visible? How To Handle It?

    There are couples of things which may cause this issue. 

    Element may not be visible in automation due to the speed of selenium.

    If you closed a hidden division pop up, and tried to perform action, then there is a chance that hidden division popup’ animation went over which could cause this issue.

    There is could be an another element which has same XPath or locator in some other page.

    Example:
    Consider you have an element which has XPath as //button [@id=’abc’] on page X, by clicking some tab on page navigates the user to MY page, Now there is an element on Y page which have XPath same as //button [@id=’abc’]. But when you launch your application, application may be directly landed on page Y. So with this scenario, if you try to perform on element on Y page it could throw an Error.

  56. 38. Explain What Is Time-out Test In Protractor?

    The Time-Out test in Protractor is nothing but time allotted to perform unit testing. If the unit test fails to finish in that specific time limit, protractor will abandon further testing and mark it as a failed.

  57. 39. How To Wait For Element To Be Available In Angular Applications?

    The application may load some elements late and your script needs to stop for the element to be available for next action.

    In below protractor code, the script is going to wait maximum 30 seconds for the element to be available. Feel free to change the maximum number per your application needs.

    browser.wait (ExpectedConditions.presenceOf (element (by.id (“element-id”))), 30000)

  58. 40. What Is The Difference Between “get” And “navigate” To Open A Web Page In Protractor?

    Get method will get a page to load or get page source or get text that’s all whereas navigate will guide through the history like refresh, back, forward.

    For example if we want to move forward and do some functionality and back to the home page this can be achieved through navigate() only.

    Browser. Get () will wait till the whole page gets loaded and browser. Navigate () will just redirect to that page and will not wait.


  59. Performance Testing Interview Questions

  60. 41. Difference Between Flex And Flash Application?

    In flash there is no code just based on creativity(design) we will complete the work(time consuming process) whereas flex contain some small functions which is integrated with mxml,PHP..(No tool is there to develop flex we want to use the properties of css and style sheet)