def test_should_update_user_name_when_edited_from_datasender_page(self): add_user_page = self.all_users_page.navigate_to_add_user() add_user_page.add_user_with(EDIT_USER_DATA) self.driver.go_to(DATA_WINNER_ALL_DATA_SENDERS_PAGE) all_datasenders_page = AllDataSendersPage(self.driver) all_datasenders_page.search_with(EDIT_USER_DATA.get('username')) self.driver.find( all_datasenders_page.get_checkbox_selector_for_datasender_row( 1)).click() all_datasenders_page.select_edit_action() EDIT_DETAILS = { "name": "New testUser", "mobile_number": EDIT_USER_DATA.get("mobile_phone"), "commune": "Madagascar", "gps": "-21.7622088847 48.0690991394" } AddDataSenderPage(self.driver).enter_data_sender_details_from( EDIT_DETAILS).navigate_to_datasender_page() self.driver.go_to(ALL_USERS_URL) self.all_users_page = AllUsersPage(self.driver) element = self.driver.find( by_xpath(NAME_COLUMN % EDIT_USER_DATA.get("username"))) self.assertEquals(EDIT_DETAILS.get("name"), element.text)
def edit_datasender(self, uid=None): if not uid: return False self.select_a_data_sender_by_id(uid) self.select_edit_action() return AddDataSenderPage(self.driver)
def setUp(self): TestAllDataSenderRegistration.driver.refresh() self.driver.go_to(DATA_WINNER_CREATE_DATA_SENDERS) self.current_page = AddDataSenderPage(self.driver)
class TestAllDataSenderRegistration(unittest.TestCase): @classmethod def setUpClass(cls): cls.driver = setup_driver() cls.driver.go_to(DATA_WINNER_LOGIN_PAGE) login_page = LoginPage(cls.driver) login_page.do_successful_login_with(VALID_CREDENTIALS) def setUp(self): TestAllDataSenderRegistration.driver.refresh() self.driver.go_to(DATA_WINNER_CREATE_DATA_SENDERS) self.current_page = AddDataSenderPage(self.driver) @classmethod def tearDownClass(cls): teardown_driver(cls.driver) def login_with_created_datasenders_account(self, email): global_navigation = GlobalNavigationPage(self.driver) global_navigation.sign_out() self.driver.go_to(DATA_WINNER_LOGIN_PAGE) data_sender_credentials = {USERNAME: email, PASSWORD: "******"} login_page = LoginPage(self.driver) login_page.login_with(data_sender_credentials) message = global_navigation.welcome_message() return message @attr('functional_test') def test_successful_addition_and_editing_of_data_sender(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(VALID_DATA) success_msg = add_data_sender_page.get_success_message() self.assertRegexpMatches(success_msg, fetch_(SUCCESS_MSG, from_(VALID_DATA))) rep_id = self._parse(success_msg) all_data_senders_page = AllDataSendersPage(self.driver) all_data_senders_page.load() all_data_senders_page.search_with(rep_id) all_data_senders_page.select_a_data_sender_by_id(rep_id) all_data_senders_page.select_edit_action() self.current_page.enter_data_sender_details_from(VALID_EDIT_DATA) self.assertRegexpMatches(self.current_page.get_success_message(), fetch_(SUCCESS_MSG, from_(VALID_EDIT_DATA))) @attr('functional_test') def test_addition_of_data_sender_without_email_address(self): add_data_sender_page = self.current_page add_data_sender_page.select_web_device() add_data_sender_page.enter_data_sender_details_from( VALID_DATA_WITHOUT_EMAIL) self.assertRegexpMatches( add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(VALID_DATA_WITHOUT_EMAIL))) @attr('functional_test') def test_addition_of_data_sender_without_entering_data(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(BLANK_FIELDS) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(BLANK_FIELDS))) a = self.driver.switch_to_active_element() self.assertEqual(a.get_attribute("id"), u"id_name") @attr('functional_test') def test_addition_of_data_sender_with_existing_data(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(EXISTING_DATA) time.sleep(1) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(EXISTING_DATA))) @attr('functional_test') def test_addition_of_data_sender_without_location_name(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from( WITHOUT_LOCATION_NAME) self.assertRegexpMatches( add_data_sender_page.get_success_message(), fetch_(SUCCESS_MSG, from_(WITHOUT_LOCATION_NAME))) @attr('functional_test') def test_addition_of_data_sender_without_gps(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(WITHOUT_GPS) self.assertRegexpMatches(add_data_sender_page.get_success_message(), fetch_(SUCCESS_MSG, from_(WITHOUT_GPS))) @attr('functional_test') def test_addition_of_data_sender_with_invalid_gps(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(INVALID_GPS) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(INVALID_GPS))) @attr('functional_test') def test_addition_of_data_sender_with_invalid_latitude_gps(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from( INVALID_LATITUDE_GPS) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(INVALID_LATITUDE_GPS))) @attr('functional_test') def test_addition_of_data_sender_with_invalid_longitude_gps(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from( INVALID_LONGITUDE_GPS) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(INVALID_LONGITUDE_GPS))) @attr('functional_test') def test_addition_of_data_sender_with_unicode_in_gps(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from( WITH_UNICODE_IN_GPS) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(WITH_UNICODE_IN_GPS))) @SkipTest def test_addition_of_data_sender_with_invalid_gps_with_comma(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from( INVALID_GPS_WITH_COMMA) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(INVALID_GPS_WITH_COMMA))) @attr('functional_test') def test_add_datasender_with_long_uid(self): add_data_sender_page = self.current_page self.driver.find(by_css("#generate_id")).click() self.driver.find_text_box( by_css("#id_short_code")).enter_text("rep012345678901234567891") short_code = self.driver.find( by_css("#id_short_code")).get_attribute('value') self.assertEquals(len(short_code), 12) def assert_fields_are_populated_properly_in_edit_page( self, valid_registration_data): self.assertEquals( fetch_(NAME, from_(valid_registration_data)), self.driver.find_text_box(NAME_TB).get_attribute('value')) self.assertEquals( fetch_(MOBILE_NUMBER, from_(valid_registration_data)), self.driver.find_text_box(MOBILE_NUMBER_TB).get_attribute('value')) self.assertEqual( fetch_(COMMUNE, from_(valid_registration_data)), self.driver.find_text_box(COMMUNE_TB).get_attribute('value')) self.assertEqual( fetch_(GPS, from_(valid_registration_data)), self.driver.find_text_box(GPS_TB).get_attribute('value')) @attr('functional_test') def test_edit_datasender_should_populate_all_fields_properly(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from( VALID_DATA_WITH_EMAIL) success_msg = self.current_page.get_success_message() rep_id = self._parse(success_msg) self.assertRegexpMatches( success_msg, fetch_(SUCCESS_MSG, from_(VALID_DATA_WITH_EMAIL))) self.driver.go_to(DATA_WINNER_ALL_DATA_SENDERS_PAGE) all_datasender_page = AllDataSendersPage(self.driver) edit_datasender_page = all_datasender_page.edit_datasender(rep_id) self.assert_fields_are_populated_properly_in_edit_page( VALID_DATA_WITH_EMAIL) edit_datasender_page.enter_data_sender_details_from( VALID_DATA_WITH_EMAIL_EDITED) self.assertRegexpMatches( edit_datasender_page.get_success_message(), fetch_(SUCCESS_MSG, from_(VALID_DATA_WITH_EMAIL_EDITED))) self.driver.go_to(DATA_WINNER_ALL_DATA_SENDERS_PAGE) all_datasender_page = AllDataSendersPage(self.driver) all_datasender_page.edit_datasender(rep_id) self.assert_fields_are_populated_properly_in_edit_page( VALID_DATA_WITH_EMAIL_EDITED) # @attr('functional_test') # def test_should_uncheck_reporter_id_checkbox_if_user_has_given_id(self): # self.driver.go_to(DATA_WINNER_CREATE_DATA_SENDERS) # add_data_sender_page = AddDataSenderPage(self.driver) # self.assertTrue(add_data_sender_page.unique_id_check_box_is_checked()) # add_data_sender_page.enter_data_sender_details_from(INVALID_MOBILE_NUMBER_DATA, "DS040") # time.sleep(1) # self.assertFalse(add_data_sender_page.unique_id_check_box_is_checked()) # self.assertTrue(add_data_sender_page.unique_id_field_is_enabled()) # def _parse(self, message): return message.split(' ')[-1]
def setUp(self): TestAllDataSenderRegistration.driver.refresh() self.driver.go_to(DATA_WINNER_CREATE_DATA_SENDERS) self.driver.find(by_id("register_link")).click() self.current_page = AddDataSenderPage(self.driver)
class TestAllDataSender(unittest.TestCase): @classmethod def setUpClass(cls): cls.driver = setup_driver() cls.driver.go_to(DATA_WINNER_LOGIN_PAGE) login_page = LoginPage(cls.driver) login_page.do_successful_login_with(VALID_CREDENTIALS) def setUp(self): TestAllDataSender.driver.refresh() self.driver.go_to(DATA_WINNER_CREATE_DATA_SENDERS) self.current_page = AddDataSenderPage(self.driver) def tearDown(self): import sys exception_info = sys.exc_info() if exception_info != (None, None, None): import os if not os.path.exists("screenshots"): os.mkdir("screenshots") self.driver.get_screenshot_as_file("screenshots/screenshot-%s-%s.png" % (self.__class__.__name__, self._testMethodName)) @classmethod def tearDownClass(cls): teardown_driver(cls.driver) def login_with_created_datasenders_account(self): self.driver.go_to(DATA_WINNER_ALL_DATA_SENDERS_PAGE) all_data_senders_page = AllDataSendersPage(self.driver) email = all_data_senders_page.get_data_sender_email_by_mobile_number(VALID_DATA_WITH_EMAIL[MOBILE_NUMBER_WITHOUT_HYPHENS]) global_navigation = GlobalNavigationPage(self.driver) global_navigation.sign_out() self.driver.go_to(DATA_WINNER_LOGIN_PAGE) data_sender_crendentials = {USERNAME: email, PASSWORD: "******"} login_page = LoginPage(self.driver) login_page.login_with(data_sender_crendentials) message = global_navigation.welcome_message() return email, message @attr('functional_test', 'smoke') def test_successful_addition_editing_of_data_sender(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(VALID_DATA) self.assertRegexpMatches(add_data_sender_page.get_success_message(), fetch_(SUCCESS_MSG, from_(VALID_DATA))) self.driver.go_to(DATA_WINNER_ALL_DATA_SENDERS_PAGE) all_data_senders_page = AllDataSendersPage(self.driver) all_data_senders_page.select_a_data_sender_by_mobile(VALID_DATA[MOBILE_NUMBER_WITHOUT_HYPHENS]) all_data_senders_page.select_edit_action() self.current_page.enter_data_sender_details_from(VALID_EDIT_DATA) self.assertRegexpMatches(self.current_page.get_success_message(), fetch_(SUCCESS_MSG, from_(VALID_EDIT_DATA))) @attr('functional_test', 'smoke') def test_successful_addition_of_data_sender_with_email_address(self): add_data_sender_page = self.current_page add_data_sender_page.select_web_device() add_data_sender_page.enter_email(VALID_DATA_WITH_EMAIL) add_data_sender_page.enter_data_sender_details_from(VALID_DATA_WITH_EMAIL) self.assertRegexpMatches(add_data_sender_page.get_success_message(), fetch_(SUCCESS_MSG, from_(VALID_DATA_WITH_EMAIL))) email, message = self.login_with_created_datasenders_account() self.assertEqual(email.lower(), email) self.assertEqual(message, "Welcome Mickey Duck!") @attr('functional_test', 'smoke') def test_addition_of_data_sender_without_email_address(self): add_data_sender_page = self.current_page add_data_sender_page.select_web_device() add_data_sender_page.enter_data_sender_details_from(VALID_DATA_WITHOUT_EMAIL) self.assertRegexpMatches(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(VALID_DATA_WITHOUT_EMAIL))) @attr('functional_test') def test_addition_of_data_sender_without_entering_data(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(BLANK_FIELDS) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(BLANK_FIELDS))) @attr('functional_test') def test_addition_of_data_sender_with_existing_data(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(EXISTING_DATA) sleep(1) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(EXISTING_DATA))) @attr('functional_test') def test_addition_of_data_sender_without_location_name(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(WITHOUT_LOCATION_NAME) self.assertRegexpMatches(add_data_sender_page.get_success_message(), fetch_(SUCCESS_MSG, from_(WITHOUT_LOCATION_NAME))) @attr('functional_test') def test_addition_of_data_sender_without_gps(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(WITHOUT_GPS) self.assertRegexpMatches(add_data_sender_page.get_success_message(), fetch_(SUCCESS_MSG, from_(WITHOUT_GPS))) @attr('functional_test') def test_addition_of_data_sender_with_invalid_gps(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(INVALID_GPS) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(INVALID_GPS))) @attr('functional_test') def test_addition_of_data_sender_with_invalid_latitude_gps(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(INVALID_LATITUDE_GPS) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(INVALID_LATITUDE_GPS))) @attr('functional_test') def test_addition_of_data_sender_with_invalid_longitude_gps(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(INVALID_LONGITUDE_GPS) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(INVALID_LONGITUDE_GPS))) @attr('functional_test') def test_addition_of_data_sender_with_unicode_in_gps(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(WITH_UNICODE_IN_GPS) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(WITH_UNICODE_IN_GPS))) @SkipTest def test_addition_of_data_sender_with_invalid_gps_with_comma(self): add_data_sender_page = self.current_page add_data_sender_page.enter_data_sender_details_from(INVALID_GPS_WITH_COMMA) self.assertEqual(add_data_sender_page.get_error_message(), fetch_(ERROR_MSG, from_(INVALID_GPS_WITH_COMMA)))