jeudi 11 janvier 2018

Page Object Mode with node, ES7, puppeteer

I recently started utilizing Puppeteer for e2e testing (I have some experience with Selenium Web Driver) and I could not find anything in the documentation discussing POM pattern. Are there any examples available how to implement this correctly in node/ES7 within Puppeteer?

Let us say I have a simple script that tests the login functionality of a page:

(async () => {
...

     await page.goto(url, {
        timeout: 5000
    });

    await page.waitFor('input[id=userId]');

    await page.type('input[id=userId]', 'John Doe');
    await page.type('input[id=password]', 'password1');
    await page.click('button[type="submit"]');
    await page.waitFor('p.success-msg');
...
}();

Typically, we would have a Page Object Model for the login page. How would I create a basic POM for the above page and integrate it with my script? I am just looking for a basic 'hello world' example.

Aucun commentaire:

Enregistrer un commentaire