Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page Objects in AngularJS Protractor E2E Testing

What is the right way to handle the Page Objects model for writing Protractor E2E testing for AngularJS? I feel like I should write them in separate files (like homepage.js, page2.js, etc) then include somehow them into the specs like modules as need. However, I don't know how to inject them. Would appreciate any suggestions. Thanks!

like image 965
wlingke Avatar asked Dec 12 '13 04:12

wlingke


People also ask

How do you make a page object on a protractor?

Page Object class contains all the page object(web elements) for a particular page. For every page present application, we have to write the Page Object class. Page Object class name should end with PO so that it will be easy for the user to identify the page object class.

Which of the following files in angular 4 is used for unit testing via the protractor?

Sample AngularJS application testing using Protractor. Protractor needs two files to run, a spec file and configuration file.

How do you run multiple specs on a protractor?

When you want to run protractor scripts by opening a browser instance for each test, you should add two capabilities shardTestFiles and maxInstances in the Capabilities block of the conf. js file. This will help to execute your scripts on same browser with multiple instances.

What is protractor in angular testing?

Protractor is a wrapper around Selenium Webdriver that provides an automation test framework, which simulates user interaction with an Angular web application for a range of browsers and mobile devices. It provides all features of Selenium WebDriver along with Angular specific features for seamless end to end testing.


1 Answers

Keep them in separate files, and use Node's require to pull in any helpers or page objects you need. Check out this super simple example: https://github.com/juliemr/ng-page-e2e/blob/master/test/angularsite_test.js#L2

like image 78
Jmr Avatar answered Oct 07 '22 17:10

Jmr