Protractor MCQs and Answers With Explanation | Protractor Quiz

Protractor MCQ's
Join Telegram Join Telegram
Join Whatsapp Groups Join Whatsapp

Protractor MCQs and Answers With Explanation – Protractor is a widely used software testing framework for Angular and AngularJS applications. It is designed to carry out end-to-end testing and is built on top of WebDriverJS, which interacts with browsers using the Selenium WebDriver protocol. Protractor uses JavaScript as its primary programming language for writing tests. In order to help aspirants who will be appearing for the interview for software testing this Protractor Online Quiz will help them in preparing for the Protractor concept easily.

Protractor MCQs

This article contains Protractor MCQs With Answers, covering topics such as its installation, configuration, test execution, and functions for interacting with elements on web pages. By going through these Protractor MCQs, readers can test their knowledge of Protractor and gain a better understanding of its capabilities.

Protractor MCQs With Answers

Name Protractor
Exam Type MCQ (Multiple Choice Questions)
Category Technical Quiz
Mode of Quiz Online

Top 45 Protractor Multiple Choice Questions

1. What is Protractor?

A. A tool for measuring angles
B. A software testing framework
C. A type of compass
D. A type of ruler

Answer: B. A software testing framework

Explanation: Protractor is an end-to-end testing framework for Angular and AngularJS applications. It is built on top of WebDriverJS, which uses the Selenium WebDriver protocol to interact with browsers.

2. Which programming language is used for writing Protractor tests?

A. Java
B. Python
C. JavaScript
D. C#

Answer: C. JavaScript

Explanation: Protractor tests are written in JavaScript, which is the primary programming language used for building Angular and AngularJS applications.

3. Which command is used to install Protractor globally?

A. npm install protractor -g
B. npm protractor install -g
C. protractor install -g
D. npm global install protractor

Answer: A. npm install protractor -g

Explanation: The npm install protractor -g command is used to install Protractor globally on your system.

4. Which command is used to update Protractor to the latest version?

A. npm update protractor
B. npm upgrade protractor
C. npm install protractor@latest
D. npm protractor update

Answer: C. npm install protractor@latest

Explanation: The npm install protractor@latest command is used to update Protractor to the latest version.

5. Which file is used to configure Protractor?

A. package.json
B. protractor.json
C. config.json
D. protractor.conf.js

Answer: D. protractor.conf.js

Explanation: The protractor.conf.js file is used to configure Protractor. It includes information about the test suite, the capabilities of the browser being used, and other settings.

6. Which command is used to run Protractor tests?

A. protractor
B. protractor run
C. npm run protractor
D. protractor start

Answer: A. protractor

Explanation: The protractor command is used to run Protractor tests. It will execute the test suite specified in the protractor.conf.js file.

7. Which command is used to run a specific Protractor test file?

A. protractor test-file.js
B. protractor –file test-file.js
C. protractor –specs test-file.js
D. protractor –test test-file.js

Answer: C. protractor –specs test-file.js

Explanation: The protractor –specs test-file.js command is used to run a specific Protractor test file.

8. Which function is used to interact with elements on a web page in Protractor?

A. element()
B. browser()
C. driver()
D. protractor()

Answer: A. element()

Explanation: The element() function is used to interact with elements on a web page in Protractor. It returns a WebElement object that can be used to perform actions on the element.

9. Which function is used to retrieve the value of an element attribute in Protractor?

A. getAttribute()
B. getText()
C. isEnabled()
D. isSelected()

Answer: A. getAttribute()

Explanation: The getAttribute() function is used to retrieve the value of an element attribute in Protractor. It takes the name of the attribute as an argument and returns the value.

10. Which function is used to simulate a mouse click on an element in Protractor?

A. click()
B. submit()
C. sendKeys()
D. clear()

Answer: A. click()

Explanation: The click() function is used to simulate a mouse click on an element in Protractor. It triggers the click event for the element.

11. Which function is used to wait for an element to be present on a web page in Protractor?

A. waitForElement()
B. wait()
C. until()
D. expect()

Answer: B. wait()

Explanation: The wait() function is used to wait for an element to be present on a web page in Protractor. It takes a condition as an argument and waits until the condition is true before continuing with the test.

12. Which function is used to compare actual and expected values in Protractor?

A. expect()
B. assert()
C. verify()
D. compare()

Answer: A. expect()

Explanation: The expect() function is used to compare actual and expected values in Protractor. It is part of the Jasmine testing framework and is used to write assertions.

13. Which function is used to select an option from a drop-down list in Protractor?

A. selectByIndex()
B. selectByValue()
C. selectByVisibleText()
D. select()

Answer: C. selectByVisibleText()

Explanation: The selectByVisibleText() function is used to select an option from a drop-down list in Protractor. It takes the visible text of the option as an argument and selects the corresponding option.

14. Which function is used to switch to a new window or tab in Protractor?

A. switchToNewWindow()
B. switchToTab()
C. switchToWindow()
D. switch()

Answer: C. switchToWindow()

Explanation: The switchToWindow() function is used to switch to a new window or tab in Protractor. It takes a window handle as an argument and switches to the corresponding window or tab.

15. Which function is used to get the URL of the current web page in Protractor?

A. getUrl()
B. getCurrentUrl()
C. getPageUrl()
D. getWebUrl()

Answer: B. getCurrentUrl()

Explanation: The getCurrentUrl() function is used to get the URL of the current web page in Protractor. It returns the current URL as a string.

16. Which function is used to get the title of the current web page in Protractor?

A. getTitle()
B. getCurrentTitle()
C. getPageTitle()
D. getWebTitle()

Answer: A. getTitle()

Explanation: The getTitle() function is used to get the title of the current web page in Protractor. It returns the title as a string.

17. Which function is used to scroll to an element on a web page in Protractor?

A. scrollIntoView()
B. scrollToElement()
C. scroll()
D. move()

Answer: A. scrollIntoView()

Explanation: The scrollIntoView() function is used to scroll to an element on a web page in Protractor. It takes the element as an argument and scrolls the page so that the element is in view.

18. Which function is used to drag and drop an element on a web page in Protractor?

A. dragAndDrop()
B. drag()
C. drop()
D. move()

Answer: A. dragAndDrop()

Explanation: The dragAndDrop() function is used to drag and drop an element on a web page in Protractor. It takes two arguments: the source element and the target element.

19. Which function is used to perform a mouse hover over an element in Protractor?

A. hover()
B. mouseOver()
C. moveMouse()
D. mouseMove()

Answer: B. mouseOver()

Explanation: The mouseOver() function is used to perform a mouse hover over an element in Protractor. It triggers the mouseover event for the element.

20. Which function is used to simulate a key press on a web page in Protractor?

A. sendKeys()
B. pressKey()
C. type()
D. keyPress()

Answer: A. sendKeys()

Explanation: The sendKeys() function is used to simulate a key press on a web page in Protractor. It takes a string as an argument and types the characters one by one.

21. Which function is used to get the value of an attribute of an element in Protractor?

A. getAttribute()
B. getValue()
C. getProp()
D. getProperty()

Answer: A. getAttribute()

Explanation: The getAttribute() function is used to get the value of an attribute of an element in Protractor. It takes the name of the attribute as an argument and returns the value as a string.

22. Which function is used to clear the text in an input field in Protractor?

A. clear()
B. clearText()
C. reset()
D. deleteText()

Answer: A. clear()

Explanation: The clear() function is used to clear the text in an input field in Protractor. It clears the existing text and makes the field empty.

23. Which function is used to perform a mouse click on an element in Protractor?

A. click()
B. mouseClick()
C. performClick()
D. doClick()

Answer: A. click()

Explanation: The click() function is used to perform a mouse click on an element in Protractor. It triggers the click event for the element.

24. Which function is used to execute a JavaScript expression on a web page in Protractor?

A. executeScript()
B. runScript()
C. evalScript()
D. executeJavaScript()

Answer: A. executeScript()

Explanation: The executeScript() function is used to execute a JavaScript expression on a web page in Protractor. It takes a string as an argument and evaluates it as JavaScript code.

25. Which function is used to switch to an iframe on a web page in Protractor?

A. switchToIframe()
B. switchToFrame()
C. switchToWindow()
D. switchToTab()

Answer: B. switchToFrame()

Explanation: The switchToFrame() function is used to switch to an iframe on a web page in Protractor. It takes the index or name of the iframe as an argument and switches to the corresponding iframe.

26. Which function is used to wait for a web page to load in Protractor?

A. waitForPageLoad()
B. waitForAngular()
C. waitForElement()
D. wait()

Answer: B. waitForAngular()

Explanation: The waitForAngular() function is used to wait for a web page to load in Protractor. It waits for Angular to finish rendering the page before continuing with the test.

27. Which function is used to get the text of an element in Protractor?
A. getText()
B. getElementText()
C. fetchText()
D. retrieveText()

Answer: A. getText()

Explanation: The getText() function is used to get the text of an element in Protractor. It returns the text as a string.

28. Which function is used to check if an element is displayed on a web page in Protractor?

A. isDisplayed()
B. isVisible()
C. isPresent()
D. isShown()

Answer: A. isDisplayed()

Explanation: The isDisplayed() function is used to check if an element is displayed on a web page in Protractor. It returns true if the element is visible and false otherwise.

29. Which function is used to check if an element is enabled on a web page in Protractor?

A. isEnabled()
B. isClickable()
C. isSelectable()
D. isEditable()

Answer: A. is Enabled

Explanation: The isEnabled() function is used to check if an element is enabled on a web page in Protractor. It returns true if the element is enabled and false otherwise.

30. Which function is used to check if an element is selected on a web page in Protractor?

A. isSelected()
B. isChosen()
C. isChecked()
D. isPicked()

Answer: A. isSelected()

Explanation: The isSelected() function is used to check if an element is selected on a web page in Protractor. It returns true if the element is selected and false otherwise.

31. Which function is used to get the location of an element on a web page in Protractor?

A. getLocation()
B. getElementLocation()
C. fetchLocation()
D. retrieveLocation()

Answer: A. getLocation()

Explanation: The getLocation() function is used to get the location of an element on a web page in Protractor. It returns an object with x and y coordinates.

32. Which function is used to get the size of an element on a web page in Protractor?

A. getSize()
B. getElementSize()
C. fetchSize()
D. retrieveSize()

Answer: A. getSize()

Explanation: The getSize() function is used to get the size of an element on a web page in Protractor. It returns an object with width and height properties.

33. Which function is used to simulate a mouse hover over an element in Protractor?
A. mouseHover()
B. hover()
C. performHover()
D. doHover()

Answer: B. hover()

Explanation: The hover() function is used to simulate a mouse hover over an element in Protractor. It triggers the mouseover event for the element.

34. Which function is used to drag and drop an element in Protractor?

A. dragAndDrop()
B. moveAndDrop()
C. performDragAndDrop()
D. doDragAndDrop()

Answer: A. dragAndDrop()

Explanation: The dragAndDrop() function is used to drag and drop an element in Protractor. It takes two arguments: the element to be dragged and the element to drop it onto.

35. Which function is used to switch to a new window on a web page in Protractor?

A. switchToWindow()
B. switchToNewWindow()
C. switchToTab()
D. switchToNextWindow()

Answer: A. switchToWindow()

Explanation: The switchToWindow() function is used to switch to a new window on a web page in Protractor. It takes the window handle as an argument and switches to the corresponding window.

36. Which function is used to get the title of a web page in Protractor?

A. getTitle()
B. getPageTitle()
C. fetchTitle()
D. retrieveTitle()

Answer: A. getTitle()

Explanation: The getTitle() function is used to get the title of a web page in Protractor. It returns the title as a string.

37. Which function is used to refresh a web page in Protractor?

A. refresh()
B. reload()
C. navigate().refresh()
D. goTo()

Answer: C. navigate().refresh()

Explanation: The navigate().refresh() function is used to refresh a web page in Protractor. It refreshes the current page by sending a new GET request to the server.

38. Which function is used to navigate to a new page in Protractor?

A. navigateTo()
B. navigate()
C. goTo()
D. moveTo()

Answer: B. navigate()

Explanation: The navigate() function is used to navigate to a new page in Protractor. It takes a URL as an argument and loads the new page.

39. Which function is used to wait for an element to be clickable on a web page in Protractor?

A. waitForClickable()
B. waitUntilClickable()
C. until.elementToBeClickable()
D. waitElementClickable()

Answer: C. until.elementToBeClickable()

Explanation: The until.elementToBeClickable() function is used to wait for an element to be clickable on a web page in Protractor. It takes the element locator as an argument and waits until the element is clickable before continuing.

40. Which function is used to wait for an element to be visible on a web page in Protractor?

A. waitForVisible()
B. waitUntilVisible()
C. until.visibilityOf()
D. waitElementVisible()

Answer: C. until.visibilityOf()

Explanation: The until.visibilityOf() function is used to wait for an element to be visible on a web page in Protractor. It takes the element locator as an argument and waits until the element is visible before continuing.

41. Which function is used to wait for a page to be loaded in Protractor?

A. waitForPageLoad()
B. waitUntilPageLoad()
C. until.stalenessOf()
D. waitPageLoad()

Answer: B. waitUntilPageLoad()

Explanation: The waitUntilPageLoad() function is used to wait for a page to be loaded in Protractor. It waits until the document.readyState property is “complete” before continuing.

42. Which function is used to perform a keyboard action on an element in Protractor?

A. sendKeys()
B. type()
C. enter()
D. keyboardAction()

Answer: A. sendKeys()

Explanation: The sendKeys() function is used to perform a keyboard action on an element in Protractor. It sends the specified keys to the element.

43. Which function is used to take a screenshot of a web page in Protractor?

A. takeScreenshot()
B. captureScreenshot()
C. screenshot()
D. grabScreenshot()

Answer: A. takeScreenshot()

Explanation: The takeScreenshot() function is used to take a screenshot of a web page in Protractor. It returns a base64-encoded PNG image.

44. Which function is used to simulate a key press in Protractor?

A. pressKey()
B. sendKeys()
C. typeKey()
D. keyPress()

Answer: A. pressKey()

Explanation: The pressKey() function is used to simulate a key press in Protractor. It takes the key to be pressed as an argument.

45. Which function is used to simulate a key release in Protractor?

A. releaseKey()
B. sendKeys()
C. typeKey()
D. keyRelease()

Answer: A. releaseKey()

Explanation: The releaseKey() function is used to simulate a key release in Protractor. It takes the key to be released as an argument.

Protractor is a powerful software testing framework for Angular and AngularJS applications. By using JavaScript as its primary programming language, Protractor allows for easy interaction with web elements and provides a variety of useful functions for writing efficient and effective tests. We hope the candidates who wish to learn more about Protractor have found this Protractor MCQs With Answers worthwhile. Keep following our Freshersnow portal regularly to get these kinds of updates.