From the course: Angular: Testing and Debugging

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

End-to-end testing with page objects

End-to-end testing with page objects - Angular Tutorial

From the course: Angular: Testing and Debugging

Start my 1-month free trial

End-to-end testing with page objects

- [Man] With Protractor, it's common to load certain pages and target certain DOM elements over and over again. Page objects make these tasks much easier by creating an interface for your tests. Angular makes a page object for us when we generate the project using Angular CLI. But for this video, let's pretend we're starting from scratch without Angular's help. I'm going to delete the content of this file so we can build our page object manually. Select all, delete. I'll start by importing some tools from Protractor. I'll make a new import statement and import browser, element, and by from Protractor. The browser object lets us navigate to specified URLs in our app, the element object lets us interact with DOM elements on a page and the by object lets us locate those elements by CSS or some other selector. These are the same tools we used in the last video when we wrote our Protractor tests. Next I'll export a simple TypeScript class. You can call your class whatever you'd like. I'll…

Contents