Commit 3cec8f1a by Jay Zoldak

Catch WebDriverException

parent b9e5ed95
from lettuce import world, step from lettuce import world, step
from common import * from common import *
import time import time
from selenium.common.exceptions import WebDriverException
from nose.tools import assert_equal from nose.tools import assert_equal
from nose.tools import assert_true from nose.tools import assert_true
...@@ -42,7 +43,11 @@ def edit_the_name_of_a_policy_key(step): ...@@ -42,7 +43,11 @@ def edit_the_name_of_a_policy_key(step):
@step(u'I press the "([^"]*)" notification button$') @step(u'I press the "([^"]*)" notification button$')
def press_the_notification_button(step, name): def press_the_notification_button(step, name):
try:
world.browser.click_link_by_text(name) 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$') @step(u'I edit the value of a policy key$')
......
...@@ -3,6 +3,7 @@ from lettuce.django import django_url ...@@ -3,6 +3,7 @@ from lettuce.django import django_url
from nose.tools import assert_true from nose.tools import assert_true
from nose.tools import assert_equal from nose.tools import assert_equal
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import WebDriverException
from terrain.factories import UserFactory, RegistrationFactory, UserProfileFactory from terrain.factories import UserFactory, RegistrationFactory, UserProfileFactory
from terrain.factories import CourseFactory, GroupFactory from terrain.factories import CourseFactory, GroupFactory
...@@ -95,9 +96,15 @@ def assert_css_with_text(css, text): ...@@ -95,9 +96,15 @@ def assert_css_with_text(css, text):
def css_click(css): def css_click(css):
''' '''
Rather than click in the middle of an element, First try to use the regular click method,
click in the upper left 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
''' '''
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) css_click_at(css)
......
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