-
Notifications
You must be signed in to change notification settings - Fork 7
/
click.ts
32 lines (28 loc) · 945 Bytes
/
click.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
import { When } from '@cucumber/cucumber';
import { ScenarioWorld } from './setup/world';
import { ValidAccessibilityRoles } from '../env/global';
import { waitFor } from '../support/wait-for-behavior';
When(
/^I click the "([^"]*)" with "([^"]*)" text$/,
async function(this: ScenarioWorld, role: ValidAccessibilityRoles, name: string) {
const {
screen: { page },
globalConfig
} = this;
const locator = await page.getByRole(role, { name, exact: true });
const result = await locator.isVisible();
if (result) await locator.click();
}
);
When(
/^I click the "([^"]*)" (?:button|link)$/,
async function(this: ScenarioWorld, name: string, role: ValidAccessibilityRoles) {
const {
screen: { page },
globalConfig
} = this;
const locator = await page.getByRole(role, { name, exact: true });
const result = await locator.isVisible();
if (result) await locator.click();
}
)