CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 21:32:00 GMT
server: Fly/6f91d33b9d (2025-10-08)
content-type: text/html; charset=utf-8
content-encoding: gzip
via: 2 fly.io, 2 fly.io
fly-request-id: 01K7AK03ZX4Y4WM7P4GTRKG186-bom
Using async/await in JavaScript in Selenium | Simon Willison’s TILs
Using async/await in JavaScript in Selenium
Thanks Stuart Langridge for showing me how to do this:
from selenium import webdriver
chromedriver_path = "/Users/simon/bin/chromedriver"
driver = webdriver.Chrome(executable_path=chromedriver_path)
script = """
done = arguments[arguments.length-1];
a1 = async () => {
return 42
};
a2 = async() => {
return await a1()+1
};
a2().then(done);
"""
output = driver.execute_async_script(script)
# output is now the Python integer 43
Related
- selenium Installing Selenium for Python on macOS with ChromeDriver - 2020-10-02
- pytest Using pytest and Playwright to test a JavaScript web application - 2022-07-24
- deno Running Python code in a Pyodide sandbox via Deno - 2023-05-10
- python Running Python code in a subprocess with a time limit - 2020-12-06
- electron Using the Chrome DevTools console as a REPL for an Electron app - 2021-08-31
- webassembly Run Python code in a WebAssembly sandbox - 2023-02-02
- python Relinquishing control in Python asyncio - 2020-12-29
- electron Testing Electron apps with Playwright and GitHub Actions - 2022-07-13
- python Using the sqlite3 Python module in Pyodide - Python WebAssembly - 2021-10-18
- shot-scraper Extracting web page content using Readability.js and shot-scraper - 2022-03-24
Created 2020-10-02T14:19:41-07:00 · Edit