Skip to content

[BUG] Syntax error in JS Page Object Model Example https://playwright.dev/docs/next/test-pom #6896

@vsravuri

Description

@vsravuri

Context:

  • Playwright Version: playwright@next
  • Operating System: Mac OS
  • Node.js version: 14.7.0
  • Browser: All

Code Snippet

// playwright-dev-page.js
exports.PlaywrightDevPage = class PlaywrightDevPage {
  constructor(page: Page) {
    this.page = page;
  }

  async goto() {
    await this.page.goto('https://playwright.dev');
  }

  async toc() {
    const text = await this.page.innerText('article ul');
    return text.split('\n').filter(line => !!line);
  }

  async getStarted() {
    await this.page.click('text=Get started');
    await this.page.waitForSelector(`text=Core concepts`);
  }

  async coreConcepts() {
    await this.getStarted();
    await this.page.click('text=Core concepts');
    await this.page.waitForSelector(`h1:has-text("Core concepts")`);
  }
}

Describe the bug

I referred to the JavaScript example provided here https://playwright.dev/docs/next/test-pom for creating page object model using playwright@next.

I got syntax error 'Unexpected token ':'

constructor(page: Page) {
this.page = page;
}

should be modified to

constructor(page) {
this.page = page;
}

Test ran after fixing the syntax error.

Request to correct the syntax error in the example.

Thanks for the detailed documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions