Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

73
Vistas
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)

7 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

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.
7 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos