def test_ep_field_labels(self): expected_labels = [u'First name', u'Last name', u'City', u'State', u'Zip', u'Birthdate'] self.assertListEqual(expected_labels, get_field_labels()) test_print('Successfully verified the following labels;', flash='!') for index, label in enumerate(expected_labels, 1): print '{0}) {1}'.format(index, label)
def test_landing_text(self): expected = "This app is designed and created for the sole use of screening QA candidates for AvantCredit, any other use is prohibitted" actual = self.get_landing_dash_text() self.assertEqual( expected, actual, msg='FAILED: expected text on landing page = "{0}", got = "{1}"'.format(expected, actual) ) test_print('Successfully verified landing page text = "{0}"'.format(actual), flash="!")
def test_forgot_password_verify_label(self): set_forgot_your_password() expected = 'Forgot your password?' actual = get_h2_label() self.assertEqual(expected, actual, msg='FAILED: expected label = "{0}", got = "{1}"'.format(expected, actual)) test_print('Successfully verified label = "{0}"'.format(actual), flash='!')
def test_login_link(self): set_log_in_link() expected_login_url = 'https://avant-qa-screening.herokuapp.com/users/sign_in' actual_url = get_current_url() self.assertEqual(expected_login_url, actual_url, msg='FAILED: expected login url = {0}, got url = {1}'.format(expected_login_url, actual_url)) test_print('Successfully verified the "Log in" link', flash='!') stop() # cleanup step
def test_h1(self): expected = "Sign Up | Sign In" self.assertEqual( expected, self.h1, msg='FAILED: expected h1 text on landing page = "{0}", got = "{1}"'.format(expected, self.h1), ) test_print('Successfully verified h1 text = "{0}"'.format(self.h1), flash="!")
def test_flow(self): FlightPageUtil.set_flight(self.browser) FlightPageUtil.set_flight_fare(self.browser) FlightPageUtil.set_login_later(self.browser) FlightPageUtil.set_passengers_first_name_last_name(self.browser) FlightPageUtil.set_passenger_title(self.browser) FlightPageUtil.set_flight_page_continue_button(self.browser) test_print(self.browser.current_url)
def test_ep_field_labels(self): expected_labels = [ u'First name', u'Last name', u'City', u'State', u'Zip', u'Birthdate' ] self.assertListEqual(expected_labels, get_field_labels()) test_print('Successfully verified the following labels;', flash='!') for index, label in enumerate(expected_labels, 1): print '{0}) {1}'.format(index, label)
def verify_invalid_email(self): actual = get_error_explanation(False) self.verify_sign_up_label() self.assertFalse(actual, msg='FAILED: expected no error explanation, but got error explanation = "{0}" on url = {1}'.format(actual, get_current_url())) test_print('Successfully verified no error explanation'.format(actual), flash='!') self.assertEqual(self.chk_url, get_current_url(), msg='FAILED: expected url = {0}, got url = {1}'.format(self.chk_url, get_current_url())) test_print('Successfully verified login was unsuccessful, user is still on the sign_up page', flash='!')
def test_valid_email_valid_pw_valid_cpw(self): create_valid_account() self.assertNotEqual( self.chk_url, get_current_url(), msg='FAILED: url = {0} - did not change after login'.format( get_current_url())) test_print('Successfully verified sign up', flash='!') stop() # cleanup step
def test_h1(self): expected = 'Sign out | Edit Profile' self.assertEqual( expected, self.h1, msg='FAILED: expected h1 text on dashboard page = "{0}", got = "{1}"' .format(expected, self.h1)) test_print('Successfully verified h1 text = "{0}"'.format(self.h1), flash='!')
def test_valid_email_valid_pw(self): set_email_field(self.valid_email) set_password_field(self.valid_pw) set_log_in_button() expected = 'https://avant-qa-screening.herokuapp.com/dashboard' actual = get_current_url() self.assertEqual(expected, actual, msg='FAILED: url expected after login = {0}, got url = {1}'.format(expected, actual)) test_print('Successfully verified login', flash='!')
def test_forgot_password_sign_up_link(self): set_forgot_your_password() set_sign_up_link() expected_signup_url ='https://avant-qa-screening.herokuapp.com/users/sign_up' actual_url = get_current_url() self.assertEqual(expected_signup_url, actual_url, msg='FAILED: expected login url = {0}, got url = {1}'.format(expected_signup_url, actual_url)) test_print('Successfully verified the "Sign up" link', flash='!') go_back()
def verify_sign_up_label(self): expected = 'Forgot your password?' actual = get_h2_label() self.assertEqual( expected, actual, msg='FAILED: expected h2 = "{0}", got h2 = "{1}" on url = {2}'. format(expected, actual, get_current_url())) test_print('Successfully verified h2 = "{0}"'.format(actual), flash='!')
def verify_invalid_sign_in(self): self.verify_log_in_label() self.assertEqual( self.chk_url, get_current_url(), msg='FAILED: expected url = {0}, got url = {1}'.format( self.chk_url, get_current_url())) test_print( 'Successfully verified login was unsuccessful, user is still on the sign_in page', flash='!')
def test_edit_your_profile_label(self): expected = 'Edit your Profile:' actual = get_h2_label() self.assertEqual( expected, actual, msg='FAILED: expected label = "{0}", got = "{1}"'.format( expected, actual)) test_print('Successfully verified label = "{0}"'.format(actual), flash='!')
def test_flow(self): HomePageUtil.set_cookie_popup(self.browser) HomePageUtil.set_one_way_trip(self.browser) HomePageUtil.set_flight_departure(self.browser) HomePageUtil.set_flight_destination(self.browser) HomePageUtil.set_departure_date(self.browser) HomePageUtil.set_adults_passengers(self.browser) HomePageUtil.set_children_passengers(self.browser) HomePageUtil.set_passenger_confirm_button(self.browser) HomePageUtil.set_search_button(self.browser) test_print(self.browser.current_url)
def test_forgot_password_verify_label(self): set_forgot_your_password() expected = 'Forgot your password?' actual = get_h2_label() self.assertEqual( expected, actual, msg='FAILED: expected label = "{0}", got = "{1}"'.format( expected, actual)) test_print('Successfully verified label = "{0}"'.format(actual), flash='!')
def test_edit_profile_text(self): expected = 'This app is designed and created for the sole use of screening QA candidates for AvantCredit, any other use is prohibitted' actual = self.get_landing_dash_text() self.assertEqual( expected, actual, msg='FAILED: expected text on dashboard page = "{0}", got = "{1}"'. format(expected, actual)) test_print( 'Successfully verified dashboard page text = "{0}"'.format(actual), flash='!')
def test_login_link(self): set_log_in_link() expected_login_url = 'https://avant-qa-screening.herokuapp.com/users/sign_in' actual_url = get_current_url() self.assertEqual( expected_login_url, actual_url, msg='FAILED: expected login url = {0}, got url = {1}'.format( expected_login_url, actual_url)) test_print('Successfully verified the "Log in" link', flash='!') stop() # cleanup step
def test_edit_profile_text2(self): expected = 'You need to edit your profile before doing any querying' actual = get_dash_ep_text() self.assertEqual( expected, actual, msg='FAILED: expected text on dashboard page = "{0}", got = "{1}"'. format(expected, actual)) test_print( 'Successfully verified dashboard page text = "{0}"'.format(actual), flash='!')
def test_payment_error_message(self): HomePageUtil.set_cookie_popup(self.browser) HomePageUtil.set_one_way_trip(self.browser) HomePageUtil.set_flight_departure(self.browser) HomePageUtil.set_flight_destination(self.browser) HomePageUtil.set_departure_date(self.browser) HomePageUtil.set_adults_passengers(self.browser) HomePageUtil.set_children_passengers(self.browser) HomePageUtil.set_passenger_confirm_button(self.browser) HomePageUtil.set_search_button(self.browser) FlightPageUtil.set_flight(self.browser) FlightPageUtil.set_flight_fare(self.browser) FlightPageUtil.set_login_later(self.browser) FlightPageUtil.set_passengers_first_name_last_name(self.browser) FlightPageUtil.set_passenger_title(self.browser) FlightPageUtil.set_flight_page_continue_button(self.browser) SeatingPageUtil.set_seating_modal(self.browser) SeatingPageUtil.set_seats(self.browser) SeatingPageUtil.set_seating_continue_button(self.browser) SeatingPageUtil.set_seating_page_dismiss_cta(self.browser) BagPageUtil.set_bag_selection(self.browser) BagPageUtil.set_bag_page_continue_button(self.browser) BagPageUtil.set_bag_page_dismiss_cta(self.browser) ExtrasPageUtil.set_extras_page_continue_button(self.browser) ExtrasPageUtil.set_extras_final_page_basket(self.browser) ExtrasPageUtil.set_basket_checkout(self.browser) PaymentPageUtil.set_email_log_in(self.browser) PaymentPageUtil.set_password_log_in(self.browser) PaymentPageUtil.set_log_in_button(self.browser) PaymentPageUtil.set_phone_number(self.browser) PaymentPageUtil.set_insurance(self.browser) PaymentPageUtil.set_payment_country_dropdown(self.browser) PaymentPageUtil.set_payment_text_fields_information( self.browser, self.payment_information) PaymentPageUtil.set_cc_expiration_month_and_year(self.browser) PaymentPageUtil.set_currency_dropdown_menu(self.browser) PaymentPageUtil.set_currency_dropdown_item(self.browser) PaymentPageUtil.set_terms_and_conditions(self.browser) PaymentPageUtil.set_pay_now_button(self.browser) time.sleep(0.6) try: error_message = self.get_payment_error_message(self.browser) test_print('Successfully verified error message: {0}'.format( error_message), flash='!') except Exception: raise AssertionError( 'ERROR: Payment error message is missing on url: "{0}" '. format(self.browser.current_url))
def test_forgot_password_sign_up_link(self): set_forgot_your_password() set_sign_up_link() expected_signup_url = 'https://avant-qa-screening.herokuapp.com/users/sign_up' actual_url = get_current_url() self.assertEqual( expected_signup_url, actual_url, msg='FAILED: expected login url = {0}, got url = {1}'.format( expected_signup_url, actual_url)) test_print('Successfully verified the "Sign up" link', flash='!') go_back()
def test_valid_email_valid_pw(self): set_email_field(self.valid_email) set_password_field(self.valid_pw) set_log_in_button() expected = 'https://avant-qa-screening.herokuapp.com/dashboard' actual = get_current_url() self.assertEqual( expected, actual, msg='FAILED: url expected after login = {0}, got url = {1}'.format( expected, actual)) test_print('Successfully verified login', flash='!')
def set_random_state_dropdown(): try: click_element(get_element_by_css('select#profile_state')) states = get_element_by_css('select#profile_state').text.split('\n') if (len(states)) < 51: raise ValueError('ERROR: did not find 51 states') random_state = states[random.randrange(len(states))] state_index = states.index(random_state) for _ in xrange(state_index): simulate_keys(get_element_by_css('select#profile_state'), 'DOWN') simulate_keys(get_element_by_css('select#profile_state'), 'ENTER') test_print('clicking state = "{0}"'.format(random_state)) except: random_state = 'AL' return random_state
def verify_invalid_email(self): actual = get_error_explanation(False) self.verify_sign_up_label() self.assertFalse( actual, msg= 'FAILED: expected no error explanation, but got error explanation = "{0}" on url = {1}' .format(actual, get_current_url())) test_print('Successfully verified no error explanation'.format(actual), flash='!') self.assertEqual( self.chk_url, get_current_url(), msg='FAILED: expected url = {0}, got url = {1}'.format( self.chk_url, get_current_url())) test_print( 'Successfully verified login was unsuccessful, user is still on the sign_up page', flash='!')
def test_flow(self): ExtrasPageUtil.set_extras_page_continue_button(self.browser) ExtrasPageUtil.set_extras_final_page_basket(self.browser) ExtrasPageUtil.set_basket_checkout(self.browser) test_print(self.browser.current_url)
def test_flow(self): SeatingPageUtil.set_seating_modal(self.browser) SeatingPageUtil.set_seats(self.browser) SeatingPageUtil.set_seating_continue_button(self.browser) SeatingPageUtil.set_seating_page_dismiss_cta(self.browser) test_print(self.browser.current_url)
def verify_sign_up_label(self): expected = 'Forgot your password?' actual = get_h2_label() self.assertEqual(expected, actual, msg='FAILED: expected h2 = "{0}", got h2 = "{1}" on url = {2}'.format(expected, actual, get_current_url())) test_print('Successfully verified h2 = "{0}"'.format(actual), flash='!')
def test_flow(self): BagPageUtil.set_bag_selection(self.browser) BagPageUtil.set_bag_page_continue_button(self.browser) BagPageUtil.set_bag_page_dismiss_cta(self.browser) test_print(self.browser.current_url)
def test_h1(self): expected = 'Sign out | Edit Profile' self.assertEqual(expected, self.h1, msg='FAILED: expected h1 text on dashboard page = "{0}", got = "{1}"'.format(expected, self.h1)) test_print('Successfully verified h1 text = "{0}"'.format(self.h1), flash='!')
def verify_invalid_sign_in(self): self.verify_log_in_label() self.assertEqual(self.chk_url, get_current_url(), msg='FAILED: expected url = {0}, got url = {1}'.format(self.chk_url, get_current_url())) test_print('Successfully verified login was unsuccessful, user is still on the sign_in page', flash='!')
def test_dashboard_text2(self): expected = 'You need to edit your profile before doing any querying' actual = get_dash_ep_text() self.assertEqual(expected, actual, msg='FAILED: expected text on dashboard page = "{0}", got = "{1}"'.format(expected, actual)) test_print('Successfully verified dashboard page text = "{0}"'.format(actual), flash='!')
def test_edit_your_profile_label(self): expected = 'Edit your Profile:' actual = get_h2_label() self.assertEqual(expected, actual, msg='FAILED: expected label = "{0}", got = "{1}"'.format(expected, actual)) test_print('Successfully verified label = "{0}"'.format(actual), flash='!')
def test_ep_fields_workaround(self): # This test is a workaround for test_ep_fields_fails # This test can also fail based on issues detailed in bug #2 report funcs = [ set_random_first_name, set_random_last_name, set_random_city, set_random_state_dropdown, set_random_zip2, set_random_birthdate ] selected = [None] # write fields in random order random_last_name = None random_city = None random_state_dropdown = None random_zip = None random_birthdate = None set_update_personal_button() for _ in funcs: random_index = None while random_index in selected: random_index = random.randrange(len(funcs)) val = funcs[random_index]() selected.append(random_index) # check profile values if random_index == 0: random_first_name = val elif random_index == 1: random_last_name = val elif random_index == 2: random_city = val elif random_index == 3: random_state_dropdown = val elif random_index == 4: random_zip = val else: random_birthdate = val set_update_personal_button() # confirm dashboard messages, links expected = 'This app is designed and created for the sole use of screening QA candidates for AvantCredit, any other use is prohibitted' actual = self.get_landing_dash_text() self.assertEqual( expected, actual, msg='FAILED: expected text on dashboard page = "{0}", got = "{1}"'. format(expected, actual)) test_print( 'Successfully verified dashboard page text = "{0}"'.format(actual), flash='!') expected = 'Succesfully updated profile' actual = get_dash_ep_text() self.assertEqual( expected, actual, msg='FAILED: expected text on dashboard page = "{0}", got = "{1}"'. format(expected, actual)) test_print( 'Successfully verified dashboard page text = "{0}"'.format(actual), flash='!') expected = 'Sign out | Edit Profile' self.assertEqual( expected, self.h1, msg='FAILED: expected h1 text on dashboard page = "{0}", got = "{1}"' .format(expected, self.h1)) test_print('Successfully verified h1 text = "{0}"'.format(self.h1), flash='!') # click edit profile and confirm values set_edit_profile_link() # fn self.assertTrue( assert_displayed(wait_for_element(value=random_first_name))) test_print( 'Successfully verified "{0}" in the first name field'.format( random_first_name), flash='!') # ln self.assertTrue( assert_displayed(wait_for_element(value=random_last_name))) test_print('Successfully verified "{0}" in the last name field'.format( random_last_name), flash='!') # city self.assertTrue(assert_displayed(wait_for_element(value=random_city))) test_print('Successfully verified "{0}" in the city field'.format( random_city), flash='!') # state self.assertTrue( assert_displayed( wait_for_element(value=str(random_state_dropdown)))) test_print('Successfully verified "{0}" in the state field'.format( random_state_dropdown), flash='!') # zip self.assertTrue(assert_displayed(wait_for_element(value=random_zip))) test_print( 'Successfully verified "{0}" in the zip field'.format(random_zip), flash='!') # birthdate self.assertTrue( assert_displayed(wait_for_element(value=random_birthdate))) test_print('Successfully verified "{0}" in the birthdate field'.format( random_birthdate), flash='!')
def test_ep_fields_workaround(self): # This test is a workaround for test_ep_fields_fails # This test can also fail based on issues detailed in bug #2 report funcs = [set_random_first_name, set_random_last_name, set_random_city, set_random_state_dropdown, set_random_zip2, set_random_birthdate] selected = [None] # write fields in random order random_last_name = None random_city = None random_state_dropdown = None random_zip = None random_birthdate = None set_update_personal_button() for _ in funcs: random_index = None while random_index in selected: random_index = random.randrange(len(funcs)) val = funcs[random_index]() selected.append(random_index) # check profile values if random_index == 0: random_first_name = val elif random_index == 1: random_last_name = val elif random_index == 2: random_city = val elif random_index == 3: random_state_dropdown = val elif random_index == 4: random_zip = val else: random_birthdate = val set_update_personal_button() # confirm dashboard messages, links expected = 'This app is designed and created for the sole use of screening QA candidates for AvantCredit, any other use is prohibitted' actual = self.get_landing_dash_text() self.assertEqual(expected, actual, msg='FAILED: expected text on dashboard page = "{0}", got = "{1}"'.format(expected, actual)) test_print('Successfully verified dashboard page text = "{0}"'.format(actual), flash='!') expected = 'Succesfully updated profile' actual = get_dash_ep_text() self.assertEqual(expected, actual, msg='FAILED: expected text on dashboard page = "{0}", got = "{1}"'.format(expected, actual)) test_print('Successfully verified dashboard page text = "{0}"'.format(actual), flash='!') expected = 'Sign out | Edit Profile' self.assertEqual(expected, self.h1, msg='FAILED: expected h1 text on dashboard page = "{0}", got = "{1}"'.format(expected, self.h1)) test_print('Successfully verified h1 text = "{0}"'.format(self.h1), flash='!') # click edit profile and confirm values set_edit_profile_link() # fn self.assertTrue(assert_displayed(wait_for_element(value=random_first_name))) test_print('Successfully verified "{0}" in the first name field'.format(random_first_name), flash='!') # ln self.assertTrue(assert_displayed(wait_for_element(value=random_last_name))) test_print('Successfully verified "{0}" in the last name field'.format(random_last_name), flash='!') # city self.assertTrue(assert_displayed(wait_for_element(value=random_city))) test_print('Successfully verified "{0}" in the city field'.format(random_city), flash='!') # state self.assertTrue(assert_displayed(wait_for_element(value=str(random_state_dropdown)))) test_print('Successfully verified "{0}" in the state field'.format(random_state_dropdown), flash='!') # zip self.assertTrue(assert_displayed(wait_for_element(value=random_zip))) test_print('Successfully verified "{0}" in the zip field'.format(random_zip), flash='!') # birthdate self.assertTrue(assert_displayed(wait_for_element(value=random_birthdate))) test_print('Successfully verified "{0}" in the birthdate field'.format(random_birthdate), flash='!')
def test_valid_email_valid_pw_valid_cpw(self): create_valid_account() self.assertNotEqual(self.chk_url, get_current_url(), msg='FAILED: url = {0} - did not change after login'.format(get_current_url())) test_print('Successfully verified sign up', flash='!') stop() # cleanup step