-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfailure-handling.spec.ts
38 lines (32 loc) · 1.13 KB
/
failure-handling.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { expect, test as base } from '@playwright/test';
import { Actor } from '@testla/screenplay';
import { BrowseTheWeb, Navigate, Click, Element } from '../src/web';
type MyActors = {
actor: Actor;
};
const test = base.extend<MyActors>({
actor: async ({ browser }, use) => {
const context = await browser.newContext();
const page = await context.newPage();
const actor = Actor.named('TestActor')
.can(BrowseTheWeb.using(page));
await use(actor);
},
});
test.describe('Testing screenplay-playwright-js failure handling', () => {
test('orSkipOnFail', async ({ actor }) => {
await actor.attemptsTo(
Navigate.to('https://google.de'),
Click.on('#not-existing-element', { timeout: 1000 }).orSkipOnFail,
);
});
test('failAsFalse', async ({ actor }) => {
await actor.attemptsTo(
Navigate.to('https://google.de'),
);
const shallBeFalse = await actor.asks(
Element.toBe.visible('#not-existing-element', { timeout: 1000 }).failAsFalse,
);
await expect(shallBeFalse).toBe(false);
});
});