question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] | Add a new `enable|disable` state to waitForSelector.

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Reactions:11
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pavelfeldmancommented, Jan 1, 2022
await expect(locator).toBeEnabled();

is a new way to asserting this.

0reactions
pjcalvocommented, Jun 15, 2021
await page.waitForFunction(() => {
   return document.querySelector('foo').enabled;
});

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…

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found