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
Created 2020-10-02T14:19:41-07:00 · Edit