As an example, I would like to introduce findByRole method that is equivalent to:
page.locator(
`role=${role}[name="${name}"]`
)
I have figured out how to add this to Page object,
#1604 (comment)
This allows me to write code like:
await page.findByRole('link', 'Services').click();
However, this breaks when chaining Locator instances, e.g.
await page
.locator('role=dialog')
- .locator('role=link[name="Create A Service"]')
+ .findByRole('link', 'Create A Service')
.click();
The above is throwing an error since .locator('role=dialog') is returning an instance of a Locator that is not aware of findByRole.
As an example, I would like to introduce
findByRolemethod that is equivalent to:I have figured out how to add this to
Pageobject,#1604 (comment)
This allows me to write code like:
However, this breaks when chaining
Locatorinstances, e.g.await page .locator('role=dialog') - .locator('role=link[name="Create A Service"]') + .findByRole('link', 'Create A Service') .click();The above is throwing an error since
.locator('role=dialog')is returning an instance of aLocatorthat is not aware offindByRole.