Created
May 12, 2016 14:18
-
-
Save jesg/3ba5dfda7316d2053b3825ba2c6e31d0 to your computer and use it in GitHub Desktop.
selenium async javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is a simple script to demonstrate long-polling for async events in the browser.