Skip to content

Instantly share code, notes, and snippets.

@kupuguy
Created October 21, 2014 12:46
Show Gist options
  • Save kupuguy/3a6393272d0f45b7f68c to your computer and use it in GitHub Desktop.
Save kupuguy/3a6393272d0f45b7f68c to your computer and use it in GitHub Desktop.
Selenium bug in Python PhantomJS webdriver
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