[Feature] | Add a new `enable|disable` state to waitForSelector.
See original GitHub issueI would like to have a page.waitForSelector
state to check for enable|disable
so that I can use the auto waiting feature when executing validations.
My use case:
- I get to a page where
buttonA
is disabled. - After I fill some fields, my website does a request and based on the response it enables
buttonA
. - Then I can change the fields, execute the requests again, and make sure that
buttonA
should be disabled again.
Note: I don’t want to click the button just validate it’s state.
Example:
expect(await page.waitForSelector('buttonA', { state: 'visible' })).toBeTruthy();
await page.click('buttonB');
expect(await page.waitForSelector('buttonA', { state: 'enabled' })).toBeTruthy();
await page.click('buttonC');
expect(await page.waitForSelector('buttonA', { state: 'disabled' })).toBeTruthy();
Issue Analytics
- State:
- Created 2 years ago
- Reactions:11
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to wait for a button to be enabled and click with ...
To wait for a button (or input) to no longer be disabled, i.e. <button id="id" disabled> use :not([disabled]) in the selector string passed ......
Read more >Page.WaitForSelectorOptions (Playwright - javadoc.io
Defaults to "visible" . Can be either: "attached" - wait for element to be present in DOM. "detached" - wait for element to...
Read more >ElementHandle | Playwright
ElementHandle prevents DOM element from garbage collection unless the handle is disposed with jsHandle.dispose(). ElementHandles are auto-disposed when ...
Read more >Page.waitForSelector() method
Promise which resolves when element specified by selector string is added to DOM. Resolves to null if waiting for hidden: true and selector...
Read more >Avoiding hard waits in Playwright and Puppeteer
waitFor (1000); // hard wait for 1000ms await ... Across multiple scripts and suites, this can add up to noticeable drag on ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
is a new way to asserting this.
Then what is the point of
page.waitForLocator({state: visible})
… That can also be checked using{trial: true}
on click…IMO I think that extending the
waitForLocator
would be a great for user experience…