Skip to content
Discussion options

You must be logged in to vote

Found the solution:

import asyncio
from functools import partial

from pydoll.browser import Chrome
from pydoll.browser.tab import Tab
from pydoll.protocol.runtime.events import (
    ConsoleAPICalledEvent,
    ConsoleAPICallType,
    RuntimeEvent,
)


async def main():
    async with Chrome() as browser:
        tab = await browser.start()
        await tab.enable_runtime_events()

        async def on_console_event(event: ConsoleAPICalledEvent):
            # Filter for log events specifically if needed
            if event['params']['type'] == ConsoleAPICallType.LOG:
                print(f"Console log: {event['params']['args'][0]['value'] if event['params']['args'] else 'No args'}")
 …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by choucavalier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant