🚀 Feature Request
Title: Add locator.waitFor({ attribute }) for waiting on attribute presence/value
Summary:
Currently the only way to wait for a locator's attribute to appear or change is via expect(locator).toHaveAttribute(...) or page.waitForFunction(...). Both work, but neither fits flows where you just want to wait (not assert) for an attribute before continuing, similar to locator.waitFor({ state: 'visible' }).
Proposal:
Extend locator.waitFor() to accept an attribute condition:
Example
await toggle.waitFor({ attribute: { name: 'aria-expanded' } });
Motivation
Clearer intent than expect(...).toHaveAttribute(...) when the goal is synchronisation, not assertion (e.g. inside a Page Object action method, where assertions don't belong).
I would not expect to write a ui test simply checking if the the sidenav is expanded. But I would have some method on my page object interacting with the side nav and I would like it to fail if the side nav is not expanded
async function expandSubMenu(){
await openSideMNavigation();
await menuItemToggle.click();
await menuItemToggle.waitFor({ attribute: { name: 'aria-expanded' } });
}
This way if something strange happens taht causes the item to close ( I have had this due to a scroll event) , the waitForr can fail.
We prefer not asserting on page objects.
🚀 Feature Request
Title: Add locator.waitFor({ attribute }) for waiting on attribute presence/value
Summary:
Currently the only way to wait for a locator's attribute to appear or change is via expect(locator).toHaveAttribute(...) or page.waitForFunction(...). Both work, but neither fits flows where you just want to wait (not assert) for an attribute before continuing, similar to locator.waitFor({ state: 'visible' }).
Proposal:
Extend locator.waitFor() to accept an attribute condition:
Example
await toggle.waitFor({ attribute: { name: 'aria-expanded' } });
Motivation
Clearer intent than expect(...).toHaveAttribute(...) when the goal is synchronisation, not assertion (e.g. inside a Page Object action method, where assertions don't belong).
I would not expect to write a ui test simply checking if the the sidenav is expanded. But I would have some method on my page object interacting with the side nav and I would like it to fail if the side nav is not expanded
async function expandSubMenu(){
await openSideMNavigation();
await menuItemToggle.click();
await menuItemToggle.waitFor({ attribute: { name: 'aria-expanded' } });
}
This way if something strange happens taht causes the item to close ( I have had this due to a scroll event) , the waitForr can fail.
We prefer not asserting on page objects.