Skip to content

Instantly share code, notes, and snippets.

@jesg
Created May 12, 2016 14:18
Show Gist options
  • Save jesg/3ba5dfda7316d2053b3825ba2c6e31d0 to your computer and use it in GitHub Desktop.
Save jesg/3ba5dfda7316d2053b3825ba2c6e31d0 to your computer and use it in GitHub Desktop.
selenium async javascript
from __future__ import print_function
from selenium import webdriver as wd
driver = wd.Chrome()
driver.get('http://www.jquery-tutorial.net/introduction/hello-world')
print(driver.title)
driver.set_script_timeout(30)
result = driver.execute_async_script("""
var done = arguments[0];
$(window).one('mouseenter', function() { done(10); });
"""
)
print(result)
# should be 10
driver.quit()
@jesg
Copy link
Author

jesg commented May 12, 2016

this is a simple script to demonstrate long-polling for async events in the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment