def opened_a_story(step): step.then('I am logged in') step.then('see the logged in home page') step.then('click on the link "Projects"') step.then('click on a project') stories = world.wait_for_many_elements('.story a', 5, 0.5) world.browser.visit('http://localhost:8000/project/1/story/4') tags = world.wait_for_many_elements('#tags', 5, 0.5) assert tags, 'This is not the story details'
def fill_a_form_with_the_next_info(step, form): form_data = step.hashes for data in form_data: name = data['name'] value = data['value'] is_input = world.wait_for_many_elements( '#%s-phase-dialog input[name=%s]' % (form, name)) if is_input: is_input.first.value = value continue is_select = world.wait_for_many_elements( '#%s-phase-dialog select[name=%s]' % (form, name)) if is_select: world.browser.select(name, value) continue
def wait_until_hidden(selector, timeout=5, interval=0.5): found = world.wait_for_many_elements(selector, timeout, interval) def element_become_hidden(): sel = 'jQuery("{0}:visible").length'.format(selector) return int(world.browser.evaluate_script(sel)) == 0 world.wait_for_condition(element_become_hidden)
def click_a_button_of_the_dialog(step, button_name): buttons = world.wait_for_many_elements('div.confirm ~ div ' 'div.ui-dialog-buttonset button') if buttons[0].text.lower() == button_name.lower(): button = buttons[0] else: button = buttons[1] assert button, 'There is no %s button in the dialog' % button button.click()
def wait_for_element(selector, timeout=5, interval=0.5, dont_fail=False): try: found = world.wait_for_many_elements(selector, timeout, interval) except AssertionError: if dont_fail: return raise return found[0]
def check_that_the_phase_has_the_edited_info(step): # import pdb # pdb.set_trace() form_data = step.hashes for data in form_data: name = data['name'] value = data['value'] is_input = world.wait_for_many_elements('div#edit-phase-dialog ' + 'input[name=%s]' % name) if is_input: assert is_input.first.value == value, \ '%s has not the expected value' continue is_select = world.wait_for_many_elements('select[name=%s]' % name) if is_select: assert is_select.first.value == value, \ '%s has not the expected value' continue
def ensure_dialog_loads(): world.browser.execute_script('$(".phase-controls").css' '("visibility","visible")') button = world.wait_for_many_elements('div.phase button')[number * 2 - 3 + nth] assert button, 'There is no %s button for phase %s' % (button_name, number) button.click() form = world.wait_for_element('#%s-phase-dialog' % button_name.lower()) try: assert form.visible except AssertionError: pass return form.visible
def click_on_a_button_of_a_phase(step, button_name, number): number = int(number) if button_name.lower() == u'edit': nth = 1 elif button_name.lower() == u'delete': nth = 2 else: assert False, 'Invalid button for phase' world.browser.execute_script('$(".phase-controls").css' '("visibility","visible")') button = world.wait_for_many_elements('div.phase button')[number * 2 - 3 + nth] assert button, 'There is no %s button for phase %s' % (button_name, number) button.click()
def see_the_board_of_stories(step): found = world.wait_for_many_elements('.stories, .ui-sortable', 5, 0.5) assert found, 'There is no board of stories'
def see_the_message_of_incorrect(step): message = world.wait_for_many_elements('.story-taken-message', 5, 0.5) assert message, 'There is not the story taken message'
def click_on_a_project(step): projects = world.wait_for_many_elements("#projects ul li a") assert projects, 'There are no projects.' projects[0].click()
def wait_for_the_requested_port(step, port): found = world.wait_for_many_elements('#%s' % port, 5, 0.5) assert found, 'This is not the %s port'
def see_a_dialog(step): dialog = world.wait_for_many_elements('div.confirm') assert dialog, 'There is no dialog' assert dialog.first.visible, 'The dialog exists, but was not shown'
def see_the_form_field(step, field_name): found = world.wait_for_many_elements('select[name=%s], input[name=%s]' % (field_name, field_name)) assert found, 'no form fields named "%s" were found' % field_name
def see_the_phase_form(step, form): found = world.wait_for_many_elements('#add-phase-dialog', 5, 0.5) assert found, 'The %s Form was not found' % form.capitalize() name = step.given(u'see the form field "name"') description = step.given(u'see the form field "description"') strories_limit = step.given(u'see the form field "stories_limit"')
def display_the_hidde_phases(step): buttons = world.wait_for_many_elements(".left-shows, .right-shows", 5, 0.5) assert buttons, 'There are no buttons.' buttons[1].click() buttons[0].click()
def see_the_story_form(step, form): found = world.wait_for_many_elements('#add-story-dialog', 5, 0.5) assert found, 'The %s Story Form was not found' % form.capitalize()
def see_that_no_error_is_reported(step): error_message = world.wait_for_many_elements('#agile-message') message_is_hidden = not error_message.first.visible assert message_is_hidden, 'An unexpected error was shown'