Made a retry_on_exception world function that will retry the given function

This commit is contained in:
JonahStanley
2013-07-11 11:17:28 -04:00
parent 1ae86673f3
commit ebc9fa9e2a
5 changed files with 48 additions and 67 deletions

View File

@@ -144,17 +144,12 @@ def log_into_studio(
world.is_css_present(signin_css)
world.css_click(signin_css)
attempt = 0
while attempt < 5:
try:
login_form = world.browser.find_by_css('form#login_form')
login_form.find_by_name('email').fill(email)
login_form.find_by_name('password').fill(password)
login_form.find_by_name('submit').click()
break
except:
attempt += 1
def fill_login_form():
login_form = world.browser.find_by_css('form#login_form')
login_form.find_by_name('email').fill(email)
login_form.find_by_name('password').fill(password)
login_form.find_by_name('submit').click()
world.retry_on_exception(fill_login_form)
assert_true(world.is_css_present('.new-course-button'))

View File

@@ -7,18 +7,14 @@ from common import *
@step('I fill in the registration form$')
def i_fill_in_the_registration_form(step):
attempt = 0
while attempt < 5:
try:
register_form = world.css_find('form#register_form')
register_form.find_by_name('email').fill('robot+studio@edx.org')
register_form.find_by_name('password').fill('test')
register_form.find_by_name('username').fill('robot-studio')
register_form.find_by_name('name').fill('Robot Studio')
register_form.find_by_name('terms_of_service').check()
break
except:
attempt += 1
def fill_in_reg_form():
register_form = world.css_find('form#register_form')
register_form.find_by_name('email').fill('robot+studio@edx.org')
register_form.find_by_name('password').fill('test')
register_form.find_by_name('username').fill('robot-studio')
register_form.find_by_name('name').fill('Robot Studio')
register_form.find_by_name('terms_of_service').check()
world.retry_on_exception(fill_in_reg_form)
@step('I press the Create My Account button on the registration form$')