Protractor Interview Questions and Answers - Part 2 (Top 21+ Questions covered)
Tags: webdev, beginners, programming, tutorial
Published: 2023-01-23 03:46:37

In this video, We are going to cover the top 21+ Protractor Interview Questions and Answers with pdf download.

{% embed https://youtu.be/c3KzyMWjU3E %}

Question 1 : How to perform certain task before running Protractor Test?
Onprepare method will be executed just before starting the execution of any test case.
Helpful in initializing the reporters

onPrepare: function() {
 jasmine.getEnv().addReporter(reporter);
},



Question 2 : How do you run headless mode browsers in Protractor ?
using --headless options in chrome and firefox arguments

Question 3 : What are the different mouse actions that can be performed?
click(element)
doubleClick(element)
contextClick(element)
mouseDown(element)
mouseUp(element)
mouseMove(element)
mouseMove(element, long xOffset, long yOffset)
dragAndDrop()

Question 4 : Write a code to wait for a particular element to be visible on a page using protractor ?
let EC = ExpectedConditions;
let condition = EC.visibilityOf(element(by.id("hidden")))
browser.wait(condition, 30000)

Question 5 : Can Protractor handle windows based pop up?
Protractor is a web automation testing tool that supports only web application testing. Therefore, windows pop up cannot be handled using Protractor.

Question 6 : How to return Javascript execution result ?
browser.executeScript("document.title"); will return null, but: 
browser.executeScript("return document.title"); will return the title of the document


Question 7 : How to fetch the current page URL in Protractor ?
browser.getCurrentUrl().then(function(url){
 console.log("Web page url is : " +url )
})

Question 8 : How To Check If An Element Is Visible With Protractor?
element(by.id("element-id")).isDisplayed().then(function(displayed){
 if(displayed){
  console.log("element is Visible")
 }else{
  console.log("element is not visible")
 }
})


Question 11 : How To Switch Between Frames using Protractor?
browser.switchTo().frame(element(by.xpath("//iframe[@src='demo.html']")).getWebElement())



Question 13 : What is directConnect in protractor conf.js file ?
directConnect is a conf.js file parameter; If true, Protractor will connect directly to the browser Drivers at the locations specified by chromeDriver and firefoxPath.

Only Chrome and Firefox are supported for direct connect.

directConnect: false/true,


Question 14 : How do you set the geckodriver path in protractor ?
geckoDriver location is used to help find the geckodriver.exe file. This will be passed to the Selenium jar as the system property webdriver.gecko.driver.

If the value is not set when launching locally, it will use the default values downloaded from the webdriver-manager.

geckoDriver: 'D:/Eclipse progs/driverserver/geckodriver.exe',

Question 15 : What is maxInstances in protractor ?
A maximum number of browser instances that can run in parallel for this set of capabilities. 

This is only needed if sharedTestFiles is true in conf.js file

-----------------------------------------------------
👪 Join our Community - http://bit.ly/learntesting2019

✅ Automation Community - https://thetestingacademy.com

🐦Follow us on Twitter  - https://twitter.com/itstechmode

📖 Like us on Facebook - https://www.facebook.com/scrolltest

🎤  Listen to our Podcast - https://anchor.fm/thetestingacademy

------------------------------------------------------

#automationtesting #manualtesting #testautomation #thetestingacademy #scrolltest

`

🚀 Tools and services I recommend:
Some of the courses that I recommend to become better Automation Tester 🙌🙌

✅Selenium Training and Certification -
https://scrolltest.com/go/edureka


✅Learn Jenkins for QA -
https://bit.ly/learnjenkins-p1


✅Programming Java -
https://bit.ly/learnjava2020-p1


✅Test Automation - 
https://bit.ly/learnautomation2020


✅API Testing - 
https://www.learnapitesting.com


✅Cypress Tutorial with LIVE Projects -
http://cypresstutorial.com