Protractor Automation Interview Questions & Answers

Protractor Automation Interview Questions

Wisdom jobs Protractor Automation Interview Questions and answers have been framed specially to get you prepared for the most frequently asked questions in many job interviews. Here we have provided Tips and Tricks for cracking Protractor Automation interview Questions. These Protractor Automation Interview questions and answers are useful for Beginner, Advanced Experienced programmers and job seekers of different experience levels. It's a good idea to go through Protractor Automation Interview Questions. All the best in your job search.

Protractor Automation Interview Questions And Answers

    1. Question 1. What Is Protractor?

      Answer :

      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. Question 2. Why Protractor And Not Selenium With Any Other Language Like Java?

      Answer :

      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. Question 3. What Are The Locators In Protractor?

      Answer :

      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

    4. Question 4. What Are Element Finder And Element Array Finder?

      Answer :

      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.

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

      Answer :

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

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

      Answer :

      Protractor, as described above, is the node.js implementation of, 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.

    7. Question 7. How To Assert Something In Protractor?

      Answer :

      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)

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

      Answer :

      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.

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

      Answer :

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

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

      Answer :

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

    11. Question 11. What Does Ignore Synchronization Do?

      Answer :

      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.

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

      Answer :

      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.

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

      Answer :

      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.

    14. Question 14. Can I Use Protractor With Typescript?

      Answer :

      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.

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

      Answer :

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

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

      Answer :

      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.

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

      Answer :

      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.

    18. Question 18. Select A Checkbox Using Protractor?

      Answer :

      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.

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

      Answer :

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

    20. Question 20. What Is Group Index In Xpath?

      Answer :

      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.

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

      Answer :

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

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

      Answer :

      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.

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

      Answer :

      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.

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

      Answer :

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

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

      Answer :

      • Click (element)
      • Double Click (element)
      • Context Click (element)
      • MouseDown (element)
      • MouseUp (element)
      • MouseMove (element)
      • MouseMove (element, long xOffset, long yOffset)
      • Drag And Drop ()

    26. Question 26. Write A Code To Wait For An Alert To Appear?

      Answer :

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

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

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

      Answer :

      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 ( ("hidden")))

      Browser. Wait (condition, 30000)

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

      Answer :

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

    29. Question 29. Return Javascript Execution Result?

      Answer :

      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.

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

      Answer :

      • Re-usability of code
      • Maximum coverage
      • Recovery scenario
      • Low cost maintenance
      • Minimal manual intervention
      • Easy Reporting
      • Logging for debugging
      • Easy Coding

    31. Question 31. What Is An Xpath?

      Answer :

      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

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

      Answer :

      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.

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

      Answer :

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

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

      Answer :

      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.

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

      Answer :

      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.

    36. Question 36. What Is Element Finder?

      Answer :

      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.

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

      Answer :

      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.

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

      Answer :

      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.

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

      Answer :

      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 ( ("element-id"))), 30000)

    40. Question 40. What Is The Difference Between "get" And "navigate" To Open A Web Page In Protractor?

      Answer :

      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.

    41. Question 41. Difference Between Flex And Flash Application?

      Answer :

      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)

Popular Interview Questions

All Interview Questions

All Practice Tests

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd Protection Status