Protractor

  • /
  • Courses

Duration

25 hours

Course Price

$ 399.00

4.5 (23)

Course Content

 
  1. About protractor
  2. Tools used for protractor
  3. Protractor installation with webdriver plugin
  4. Execution of sample program using visual studio
  5. Spec and conf file explanation
  6. Protractor APIs
  7. Locators
  8. Basics of javascript/typescript
  9. Verification of messages(Error / tooltip)
  10. Promise in protractor
  11. Switch to commands
  12. Action classes
  13. Upload and downloads
  14. Screenshots
  15. Calendar handle
  16. Javascript executor for scroll
  17. POM
  18. Hybrid framework
  19. Read external Data
  20. Reports
  21. Integration (Gitlab/jenkins)

Trainer Profile

Interview Questions & Answer

 

1)What do you mean by Protractor?

Protractor is an end-to-end test framework for Angular and Angular JS applications. Protractor runs tests against your application running in a real browser, interacting with it as a user would. Protractor is a node.js port of the webdriver.io, which is the JavaScript implementation of Selenium framework.
it  is a Node.js program that supports test frameworks like Jasmine, Mocha, and Cucumber.

 

2)How Protractor, Selenium Server, and Selenium WebDriver work together?

Protractor is an end-to-end test framework for AngularJS applications. It  is a Node.js program that supports the Jasmine and Mocha test frameworks.
Selenium is a browser automation framework. Selenium includes the Selenium Server, the WebDriver APIs, and the WebDriver browser drivers.
 So,Protractor works in conjunction with Selenium to provide an automated test infrastructure that can simulate a user’s interaction with an Angular application running in a browser or mobile device.

 

3)What is Mocha?

Mocha is a JavaScript test framework for Node.js programs. It features browser support, asynchronous testing, test coverage reports, and use of any assertion library.

 

4)What is Jasmine?

Jasmine is an open source testing framework for JavaScript. It runs on any JavaScript-enabled platform. It doesn’t require a DOM. it has a clean, obvious syntax so that we can easily write tests.

 

5)How do you verify tooltip text using Protractor?

We can verify tooltip text using protractor by fetching the value of ‘title’ attribute.

element(by.id("some")).getAttribute("title").then(function(tooltip){

                        console.log(tooltip)

}

 

6)How to get text from a textbox in Protractor?

We can get it by using getAttribute method by passing argument as value. getAttribute() method returns a promise which contains String

Syntax:

element(by.xpath("text box xpath").getAttribute("value")).then(function(textValue){

console.log(textValue)

});

 

7)How to set value to prompt Alert in Protractor?

We can set values by using sendKeys() method of Alerts class, we set value to the prompt Alert in Protractor.

browser.switchTo().alert().sendKeys("softwaretestingmaterial")

 

8)How to use custom locator for Protractor?

This can be done  using  addLocator  method. Add a locator to this instance of ProtractorBy. This locator can then be used with element(by.locatorName(args)).

Example:

// Add the custom locator.

by.addLocator('buttonTxt', function(buttonTxt, opt_parent, opt_rootSelector) {

});

 

9)How Can You Do Reporting In Protractor?

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

 

10)How to Run Multiple Specs In Protractor?

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

For example, 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.

 

11)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)

 

12)Can I use Protractor for non Angular JS Apps?

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

 

13)How to assert something in Protractor?

 It depends on the assertion framework which we are 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)

 

14)if one do not want to start the Selenium server every time. How can one overcome this?

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

 

15)Write a code to wait for an alert to appear in protractor?

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

browser.wait(ExpectedConditions.alertIsPresent(), 30000);

 

 

Blog

Register For Online Demo


Can't read the image? click here to refresh