We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 82cab51 commit bd121c4Copy full SHA for bd121c4
selenium/async-javascript-in-selenium.md
@@ -0,0 +1,23 @@
1
+# Using async/await in JavaScript in Selenium
2
+
3
+Thanks [Stuart Langridge](https://twitter.com/sil/status/1312137808111304704) for showing me how to do this:
4
5
+```python
6
+from selenium import webdriver
7
8
+chromedriver_path = "/Users/simon/bin/chromedriver"
9
+driver = webdriver.Chrome(executable_path=chromedriver_path)
10
11
+script = """
12
+done = arguments[arguments.length-1];
13
+a1 = async () => {
14
+ return 42
15
+};
16
+a2 = async() => {
17
+ return await a1()+1
18
19
+a2().then(done);
20
+"""
21
+output = driver.execute_async_script(script)
22
+# output is now the Python integer 43
23
+```
0 commit comments