def submit_data_to_register_page(driver, registrant): driver.get(base_url + 'register') wait = WebDriverWait(driver, driver_wait_time) wait.until(ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Register')) for key, value in registrant.items(): driver.find_element_by_id(key).send_keys(value) puzzle_text = driver.find_element_by_id('puzzle_label').text driver.find_element_by_id('puzzle').send_keys(eval(puzzle_text)) button = wait.until(ecs.element_to_be_clickable((By.ID, 'submit'))) assert 'Register' == button.text assert 'registerUser(true)' == button.get_attribute('onclick') button.click()
def submit_data_to_register_page(driver, registrant): driver.get(base_url + 'register') assert ' – Registration' in driver.find_element_by_class_name( 'pagetitle').text for key, value in registrant.items(): driver.find_element_by_id(key).send_keys(value) puzzle_text = driver.find_element_by_id('puzzle_label').text driver.find_element_by_id('puzzle').send_keys(eval(puzzle_text)) button = WebDriverWait(driver, 1).until( ecs.element_to_be_clickable((By.ID, 'submit'))) assert 'Register' in button.text assert 'registerUser()' in button.get_attribute('onclick') button.click()
def test_registered_user_can_successfully_login(driver, registrant): register_user(driver, registrant) driver.get(base_url + 'login') wait = WebDriverWait(driver, driver_wait_time) wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Login')) driver.find_element_by_id('email').send_keys(registrant['email']) driver.find_element_by_id('passphrase').send_keys(registrant['passphrase']) button = wait.until(ecs.element_to_be_clickable((By.ID, 'login'))) button.click() wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), 'Login Successful'))
def test_can_amend_registration_record(driver, registrant): register_and_login_user(driver, registrant) driver.get(base_url + 'registration_update') wait = WebDriverWait(driver, driver_wait_time) wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Registration Details Updating')) assert 'India' == Select( driver.find_element_by_id('country')).first_selected_option.text driver.find_element_by_id('name').send_keys('Jo Bloggs') button = wait.until(ecs.element_to_be_clickable((By.ID, 'submit'))) assert 'Save' == driver.find_element_by_id('submit').text assert 'registerUser(false)' == button.get_attribute('onclick') button.click() wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Registration Update Successful')) assert 'Your registration details were successfully updated.' in driver.find_element_by_id( 'content').text
def test_can_amend_the_first_submitted_proposal(driver, registrant, proposal_single_presenter): register_and_login_user(driver, registrant) driver.get(base_url + 'proposal_update/1') wait = WebDriverWait(driver, driver_wait_time) wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Update a proposal')) title_element = driver.find_element_by_id('title') assert proposal_single_presenter['title'] == title_element.get_attribute( 'value') assert '' == title_element.text assert proposal_single_presenter['summary'] == driver.find_element_by_id( 'summary').text assert proposal_single_presenter['session_type'] == Select( driver.find_element_by_id( 'session_type')).first_selected_option.get_attribute('value') assert proposal_single_presenter['audience'] == Select( driver.find_element_by_id( 'audience')).first_selected_option.get_attribute('value') assert proposal_single_presenter['notes'] == driver.find_element_by_id( 'notes').text assert proposal_single_presenter[ 'constraints'] == driver.find_element_by_id('constraints').text new_title = 'This is a new title for a proposal' title_element.clear() title_element.send_keys(new_title) assert new_title == title_element.get_attribute('value') assert '' == title_element.text name_field = driver.find_element_by_id('name_0_field') assert proposal_single_presenter['presenters'][0][ 'name'] == name_field.get_attribute('value') assert '' == name_field.text new_presenter_name = 'Monty the Gerbil' name_field.clear() name_field.send_keys(new_presenter_name) assert new_presenter_name == name_field.get_attribute('value') assert '' == name_field.text submit_button = wait.until(ecs.element_to_be_clickable((By.ID, 'submit'))) assert 'Update' == driver.find_element_by_id('submit').text assert 'submitProposal(1)' == submit_button.get_attribute('onclick') submit_button.click() wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Proposal Update Successful')) assert 'you have successfully updated your proposal for the ACCU' in driver.find_element_by_id( 'content').text
def test_logged_in_reviewer_can_review_submitted_proposal( driver, registrant, proposal_single_presenter, reviewer): register_user(driver, registrant) submit_a_proposal(driver, registrant, proposal_single_presenter) register_a_reviewer(driver, reviewer) login_user(driver, reviewer) driver.get(base_url + 'review_list') wait = WebDriverWait(driver, driver_wait_time) wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – List of Proposals')) link = wait.until( ecs.element_to_be_clickable( (By.LINK_TEXT, proposal_single_presenter['title']))) link.click() wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Proposal to Review')) driver.find_element_by_id('score').send_keys(typed_score) driver.find_element_by_id('comment-for-proposer').send_keys( typed_comment_for_proposer) driver.find_element_by_id('comment-for-committee').send_keys( typed_comment_for_committee) submit_button = wait.until(ecs.element_to_be_clickable((By.ID, 'submit'))) assert 'Submit' == submit_button.text assert 'submitScoreAndComment(1)' == submit_button.get_attribute('onclick') submit_button.click() wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Proposal to Review')) assert 'Review stored.' == driver.find_element_by_id('alert').text assert typed_score == driver.find_element_by_id('score').get_attribute( 'value') assert typed_comment_for_proposer == driver.find_element_by_id( 'comment-for-proposer').get_attribute('value') assert typed_comment_for_committee == driver.find_element_by_id( 'comment-for-committee').get_attribute('value') logout_user(driver, reviewer)
def test_logged_in_reviewer_can_move_to_previous_proposal(driver): driver.get(base_url + 'review_proposal/2') wait = WebDriverWait(driver, driver_wait_time) wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Proposal to Review')) previous_button = wait.until( ecs.element_to_be_clickable((By.ID, 'review-previous'))) assert 'Previous' == previous_button.text assert 'navigatePrevious(2)' == previous_button.get_attribute('onclick') previous_button.click() # Travis-CI requires an extra wait here for some reason. time.sleep(1) wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Proposal to Review')) assert base_url + 'review_proposal/1' == driver.current_url # This is a scored proposal so make sure the scores are present. assert typed_score == driver.find_element_by_id('score').get_attribute( 'value') assert typed_comment_for_proposer == driver.find_element_by_id( 'comment-for-proposer').text assert typed_comment_for_committee == driver.find_element_by_id( 'comment-for-committee').text
def test_malformed_data_cases_local_error(email, passphrase, error_key, error_message, driver): driver.get(base_url + 'login') wait = WebDriverWait(driver, driver_wait_time) wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Login')) driver.find_element_by_id('email').send_keys(email) driver.find_element_by_id('passphrase').send_keys(passphrase) button = wait.until(ecs.element_to_be_clickable((By.ID, 'login'))) button.click() WebDriverWait(driver, driver_wait_time).until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Login')) assert 'Problem with login form, not submitting.' in driver.find_element_by_id( 'alert').text assert driver.find_element_by_id(error_key + '_alert').text == error_message
def test_amending_a_score_doesnt_create_a_second_score_object(driver): driver.get(base_url + 'review_proposal/1') wait = WebDriverWait(driver, driver_wait_time) wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Proposal to Review')) new_score = '8' new_comment_for_proposer = 'OK_ish.' new_comment_for_committee = 'Not entirely crap.' score_node = driver.find_element_by_id('score') score_node.clear() score_node.send_keys(new_score) comment_for_proposer_node = driver.find_element_by_id( 'comment-for-proposer') comment_for_proposer_node.clear() comment_for_proposer_node.send_keys(new_comment_for_proposer) comment_for_committee_node = driver.find_element_by_id( 'comment-for-committee') comment_for_committee_node.clear() comment_for_committee_node.send_keys(new_comment_for_committee) submit_button = wait.until(ecs.element_to_be_clickable((By.ID, 'submit'))) assert 'Update' == submit_button.text assert 'submitScoreAndComment(1)' == submit_button.get_attribute('onclick') submit_button.click() wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Proposal to Review')) assert 'Review stored.' == driver.find_element_by_id('alert').text assert new_score == driver.find_element_by_id('score').get_attribute( 'value') assert new_comment_for_proposer == driver.find_element_by_id( 'comment-for-proposer').get_attribute('value') assert new_comment_for_committee == driver.find_element_by_id( 'comment-for-committee').get_attribute('value') next_button = wait.until( ecs.element_to_be_clickable((By.ID, 'review-next'))) assert 'Next' == next_button.text assert 'navigateNext(1)' == next_button.get_attribute('onclick') next_button.click() # Travis-CI requires an extra wait here for some reason. time.sleep(2) wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Proposal to Review')) previous_button = wait.until( ecs.element_to_be_clickable((By.ID, 'review-previous'))) assert 'Previous' == previous_button.text assert 'navigatePrevious(2)' == previous_button.get_attribute('onclick') previous_button.click() # Travis-CI requires an extra wait here for some reason. time.sleep(2) wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Proposal to Review')) assert base_url + 'review_proposal/1' == driver.current_url assert new_score == driver.find_element_by_id('score').get_attribute( 'value') assert new_comment_for_proposer == driver.find_element_by_id( 'comment-for-proposer').text assert new_comment_for_committee == driver.find_element_by_id( 'comment-for-committee').text
def test_anyone_can_successfully_register(driver, registrant): submit_data_to_register_page(driver, registrant) WebDriverWait(driver, driver_wait_time).until(ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Registration Successful')) assert 'You have successfully registered for submitting proposals for the ACCU' in driver.find_element_by_id('content').text
def test_single_error_causing_local_failure(key, value, message, driver, registrant, monkeypatch): monkeypatch.setitem(registrant, key, value) submit_data_to_register_page(driver, registrant) WebDriverWait(driver, driver_wait_time).until(ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Register')) assert 'Problem with form, not submitting.' == driver.find_element_by_id('alert').text assert message in driver.find_element_by_id(key + '_alert').text
def test_can_submit_a_single_presenter_proposal(driver, registrant, proposal_single_presenter): register_and_login_user(driver, registrant) driver.get(base_url + 'submit') wait = WebDriverWait(driver, driver_wait_time) wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Submit')) driver.find_element_by_id('title').send_keys( proposal_single_presenter['title']) Select(driver.find_element_by_id('session_type')).select_by_value( proposal_single_presenter['session_type']) driver.find_element_by_id('summary').send_keys( proposal_single_presenter['summary']) Select(driver.find_element_by_id('audience')).select_by_value( proposal_single_presenter['audience']) driver.find_element_by_id('notes').send_keys( proposal_single_presenter['notes']) driver.find_element_by_id('constraints').send_keys( proposal_single_presenter['constraints']) presenter = proposal_single_presenter['presenters'][0] for key in presenter.keys(): if key == 'is_lead': selected = driver.find_element_by_id(key + '_0_field').is_selected() if (presenter[key] and not selected) or (not presenter[key] and selected): driver.find_element_by_id(key + '_0_field').click() elif key == 'country': Select(driver.find_element_by_id(key + '_0_field')).select_by_value( presenter[key]) else: element = driver.find_element_by_id(key + '_0_field') element.clear() element.send_keys(presenter[key]) button = wait.until(ecs.element_to_be_clickable((By.ID, 'submit'))) assert 'Submit' == button.text assert 'submitProposal()' == button.get_attribute('onclick') button.click() wait.until( ecs.text_to_be_present_in_element((By.CLASS_NAME, 'pagetitle'), ' – Submission Successful')) assert 'Thank you, you have successfully submitted a proposal for the ACCU' in driver.find_element_by_id( 'content').text