Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
Playwright wait on custom events

I am using Playwright in Python, and I want to inject javascript into a page that watches DOM mutations and fires custom events, and catch those events in Python.

This is an example python script:

page.evaluate("//js code that essentially dispatches new CustomEvent('newPosts')")
page.on("newPosts", handle_posts)

So far, nothing happens on Python side, as if events do not exist.

If I manually check browser console, I can see events firing just fine on browser side (which I'm catching with document.addEventListener('newPosts', fn)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I would do this:

  1. Register a listener with expose_function.
  2. Use evaluate to register a listener to newPosts. A Listener on the browser side.
  3. Inside that listener call the function you exposed on 1.
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!