Skip to content

Commit dd5bbb6

Browse files
authored
Merge pull request #74 from testla-project/fix/type-issues-for-lazy-selector
fixed issue with input type lazy selector for getElement
2 parents 7a81d06 + de5ae1b commit dd5bbb6

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

__tests__/web.spec.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import {
33
BrowserContext, Cookie,
44
test as base,
5-
expect,
5+
expect, Locator,
66
} from '@playwright/test';
77
import { Actor } from '@testla/screenplay';
88
import { BrowseTheWeb } from '../src/web/abilities/BrowseTheWeb';
@@ -149,6 +149,8 @@ test.describe('Testing screenplay-playwright-js web module', () => {
149149
// exact 1 element to find
150150
await expect(await actor.attemptsTo(Get.element('h3'))).toHaveCount(1);
151151
await expect((await actor.attemptsTo(Get.elements('h3'))).length).toBe(1);
152+
// test for deprecated function inside BrowseTheWeb
153+
await expect(((await BrowseTheWeb.as(actor).getElement((page) => page.getByRole('heading'), false) as Locator[])).length).toBe(1);
152154
});
153155

154156
test('Count', async ({ actor }) => {

src/web/abilities/BrowseTheWeb.ts

+2
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,8 @@ export class BrowseTheWeb extends Ability {
614614
if (typeof selector === 'string') {
615615
await this.page.waitForSelector(selector, { timeout: selectorOptions?.timeout });
616616
locators = await this.page.locator(selector, { hasText: selectorOptions?.hasText });
617+
} else if (typeof selector === 'function') {
618+
locators = selector(this.page);
617619
} else {
618620
locators = selector;
619621
}

0 commit comments

Comments
 (0)