Skip to content

Commit

Permalink
docs: how to use with Playwright (#2489)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfgreffier committed Nov 3, 2023
1 parent 18bbc3a commit 0ad88a6
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions docs/guide/frameworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,39 @@ describe('Testing the application', () => {
});
});
```

## Playwright

Integration with [Playwright](https://playwright.dev/) is also easy:

```ts
import { faker } from '@faker-js/faker/locale/en';
import { expect, test } from '@playwright/test';

test.describe('Testing the application', () => {
test('should create an account with username and password', async ({
page,
}) => {
const username = faker.internet.userName();
const password = faker.internet.password();
const email = faker.internet.exampleEmail();

// Visit the webpage and create an account.
await page.goto('https://www.example.com/register');
await page.getByLabel('email').fill(email);
await page.getByLabel('username').fill(username);
await page.getByLabel('password', { exact: true }).fill(password);
await page.getByLabel('confirm password').fill(password);
await page.getByRole('button', { name: 'Register' }).click();

// Now, we try to login with these credentials.
await page.goto('https://www.example.com/login');
await page.getByLabel('email').fill(email);
await page.getByLabel('password').fill(password);
await page.getByRole('button', { name: 'Login' }).click();

// We should have logged in successfully to the dashboard page.
await expect(page).toHaveURL(/.*dashboard/);
});
});
```

0 comments on commit 0ad88a6

Please sign in to comment.