Is it possible to execute script immediately after the page is navigated to? #179
Answered
by
thalissonvs
Vincent-Lin-UF
asked this question in
Q&A
-
Right now the |
Beta Was this translation helpful? Give feedback.
Answered by
thalissonvs
Jun 25, 2025
Replies: 1 comment 2 replies
-
Hi, you can use a CDP command for that: import asyncio
from pydoll.browser import Chrome
from pydoll.commands.page_commands import PageCommands
async def main():
browser = Chrome()
tab = await browser.start()
await tab._execute_command(
PageCommands.add_script_to_evaluate_on_new_document(
source='''
document.body.style.backgroundColor = 'red';
''',
run_immediately=True,
)
)
await tab.go_to('https://google.com/')
asyncio.run(main()) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's also another way, using events: