Created
October 21, 2014 12:46
-
-
Save kupuguy/3a6393272d0f45b7f68c to your computer and use it in GitHub Desktop.
Selenium bug in Python PhantomJS webdriver
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
import unittest | |
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
from selenium.webdriver.support.wait import WebDriverWait | |
from selenium.webdriver.support import expected_conditions | |
from selenium.common.exceptions import TimeoutException | |
def wait_for_alert(driver): | |
browser = driver() | |
browser.get('http://www.google.com') | |
try: | |
WebDriverWait(browser, 2).until(expected_conditions.alert_is_present(), | |
'Timed out waiting for alert') | |
except TimeoutException: | |
print("ok!") | |
finally: | |
browser.quit() | |
if __name__=='__main__': | |
wait_for_alert(webdriver.Firefox) | |
wait_for_alert(webdriver.PhantomJS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment