Made a retry_on_exception world function that will retry the given function
This commit is contained in:
@@ -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'))
|
||||
|
||||
|
||||
|
||||
@@ -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$')
|
||||
|
||||
Reference in New Issue
Block a user