Commit 3cec8f1a by Jay Zoldak

Catch WebDriverException

parent b9e5ed95
from lettuce import world, step
from common import *
import time
from selenium.common.exceptions import WebDriverException
from nose.tools import assert_equal
from nose.tools import assert_true
......@@ -42,7 +43,11 @@ def edit_the_name_of_a_policy_key(step):
@step(u'I press the "([^"]*)" notification button$')
def press_the_notification_button(step, name):
world.browser.click_link_by_text(name)
try:
world.browser.click_link_by_text(name)
except WebDriverException, e:
css = 'a.%s-button' % name.lower()
css_click_at(css)
@step(u'I edit the value of a policy key$')
......
......@@ -3,6 +3,7 @@ from lettuce.django import django_url
from nose.tools import assert_true
from nose.tools import assert_equal
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import WebDriverException
from terrain.factories import UserFactory, RegistrationFactory, UserProfileFactory
from terrain.factories import CourseFactory, GroupFactory
......@@ -95,10 +96,16 @@ def assert_css_with_text(css, text):
def css_click(css):
'''
Rather than click in the middle of an element,
click in the upper left
First try to use the regular click method,
but if clicking in the middle of an element
doesn't work it might be that it thinks some other
element is on top of it there so click in the upper left
'''
css_click_at(css)
try:
assert_true(world.browser.is_element_present_by_css(css, 5))
world.browser.find_by_css(css).first.click()
except WebDriverException, e:
css_click_at(css)
def css_click_at(css, x=10, y=10):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment