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.

[Question] page.waitForEvent supported?

See original GitHub issue

I don’t see a waitForEvent in the java version of playwright. Is it supported?

https://playwright.dev/docs/api/class-page#pagewaitforeventevent-optionsorpredicate

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yury-scommented, Mar 26, 2021

Page.waitForFunction is likely what you need. You can do something like this:

// Get a handle to a promise in the page that resolves when the event is fired
JSHandle promise = page.evaluateHandle("() => {" +
  "  const p = new Promise(r => {\n" +
  "    const listener = e => {\n" +
  "      document.removeEventListener('my-event', listener);\n" +
  "      r('done');\n" +
  "    };\n" +
  "    document.addEventListener('my-event', listener);\n" +
  "  });" +
  "  return { p };" +
  "}");
// Do something that eventually triggers the event
page.evaluate("setTimeout(() => document.dispatchEvent(new Event('my-event')), 1000)");
// Wait for the promise to get fulfilled
JSHandle result = page.waitForFunction("arg => arg.p", promise);
System.out.println(result.jsonValue());
1reaction
chaganiucommented, Apr 22, 2021

i’m using Ag-Grid to display data. When the user uses the filter functionality of the grid it takes a couple seconds for the grid to update. Ag-Grid emits events (https://www.ag-grid.com/javascript-grid/grid-events/) when things happen in the grid and i wanted to listen for the filterChanged or modelUpdated event so my UI tests will know when the grid has finished filtering.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Feature] Add page.waitForPageEvent() function · Issue #15440
page.waitForEvent() confusingly doesn't wait for page events #6220. The workaround is to use page.evaluate() #6220 (comment) but there's no ...
Read more >
BLE::waitForEvent() - Question - Mbed
Hello. I'm using mbed board Ty51822r3 with nRF51822. In this environment, BLE::waitforEvent is transported to nRF5xn::waitForEvent(). nRF5xn.
Read more >
Playwright: how to wait until there is no animation on the page?
There are several options that may help you. 1. Solution 1: First, you can maybe determine which element is loading last, and then...
Read more >
Pega Robotics wait page refresh | Support Center
I'm wondering what is the best way to wait on a page refresh / postback. ... WaitForEvent Created will only be satisfied by...
Read more >
Migrating from Puppeteer to Playwright - Checkly
Playwright offers cross-browser support out of the box, and you can choose ... waitForEvent('download'), page.click('#orders > ul > li:nth-child(1) > a') ...
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