Skip to content

Latest commit

 

History

History
23 lines (19 loc) · 553 Bytes

async-javascript-in-selenium.md

File metadata and controls

23 lines (19 loc) · 553 Bytes

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