4. Creating Page Objects with ES6 Classes

ES6 Page Object Pattern

class HomePage {
  constructor(page) {
    this.page = page;
    this.coursesLink = page.getByRole("link", { name: "Courses" });
  }

async navigateToCourses() {
await this.coursesLink.click();
}
}

Task

  • Implement `navigateToCourses` by clicking `this.coursesLink`.
💡Common doubts
Did you like the problem?
Lesson 4 of 4
JavaScript
Loading code editor…