def test_add_new_contact(self): # https://moztrap.mozilla.org/manage/case/1309/ self.contact = MockContact() contacts_app = Contacts(self.marionette) contacts_app.launch() new_contact_form = contacts_app.tap_new_contact() # Enter data into fields new_contact_form.type_given_name(self.contact['givenName']) new_contact_form.type_family_name(self.contact['familyName']) new_contact_form.type_phone(self.contact['tel']['value']) new_contact_form.type_email(self.contact['email']) new_contact_form.type_street(self.contact['street']) new_contact_form.type_zip_code(self.contact['zip']) new_contact_form.type_city(self.contact['city']) new_contact_form.type_country(self.contact['country']) new_contact_form.type_comment(self.contact['comment']) new_contact_form.tap_done() self.wait_for_condition(lambda m: len(contacts_app.contacts) == 1) self.assertEqual(contacts_app.contacts[0].name, self.contact['givenName'])
def test_add_new_contact(self): # https://moztrap.mozilla.org/manage/case/1309/ self.contact = MockContact() contacts_app = Contacts(self.marionette) contacts_app.launch() new_contact_form = contacts_app.tap_new_contact() # Enter data into fields new_contact_form.type_given_name(self.contact['givenName']) new_contact_form.type_family_name(self.contact['familyName']) new_contact_form.type_phone(self.contact['tel']['value']) # Bug 862053 is preventing us from typing in these fields # TODO: Re-enable these types once the bug has been fixed # new_contact_form.type_email(self.contact['email']) # new_contact_form.type_street(self.contact['street']) # new_contact_form.type_zip_code(self.contact['zip']) # new_contact_form.type_city(self.contact['city']) # new_contact_form.type_country(self.contact['country']) # new_contact_form.type_comment(self.contact['comment']) new_contact_form.tap_done() self.wait_for_condition(lambda m: len(contacts_app.contacts) == 1) self.assertEqual(contacts_app.contacts[0].name, self.contact['givenName'])
def test_change_keyboard_language_settings(self): settings = Settings(self.marionette) settings.launch() keyboard_settings = settings.open_keyboard_settings() # Tap on active keyboard link select_keyboard = keyboard_settings.tap_active_keyboard() # Tap 'add more keyboards' button add_more_keyboards = select_keyboard.tap_add_more_keyboards() # Select keyboard language add_more_keyboards.select_language('Spanish') # launch the Contacts app to verify the keyboard layout contacts_app = Contacts(self.marionette) contacts_app.launch() new_contact_form = contacts_app.tap_new_contact() new_contact_form.type_given_name('') # Switch to keyboard frame and switch language new_contact_form.keyboard.switch_to_keyboard() new_contact_form.keyboard.tap_keyboard_language_key() self.wait_for_element_displayed(*self._special_key_locator) special_key = self.marionette.find_element(*self._special_key_locator).text # Checking if exists the special key - "ñ" self.assertEqual(special_key, self._expected_key)
def test_change_keyboard_language_settings(self): settings = Settings(self.marionette) settings.launch() keyboard_settings = settings.open_keyboard_settings() # Tap 'add more keyboards' button add_more_keyboards = keyboard_settings.tap_add_more_keyboards() # Select keyboard language, then click back to make it "stick" add_more_keyboards.select_language(u'Espa\u00F1ol') add_more_keyboards.go_back() keyboard_settings.wait_for_built_in_keyboard(u'Espa\u00F1ol') # launch the Contacts app to verify the keyboard layout contacts_app = Contacts(self.marionette) contacts_app.launch() new_contact_form = contacts_app.tap_new_contact() new_contact_form.type_given_name('') # Switch to keyboard frame and switch language new_contact_form.keyboard.switch_to_keyboard() new_contact_form.keyboard.tap_keyboard_language_key() new_contact_form.keyboard.switch_to_keyboard() special_key = self.marionette.find_element(*self._special_key_locator).text # Checking if exists the special key - "ñ" self.assertEqual(special_key, self._expected_key)
def test_keyboard_basic(self): # Use the contacts app to enter some text contact = MockContact() contacts_app = Contacts(self.marionette) contacts_app.launch() new_contact_form = contacts_app.tap_new_contact() new_contact_form.type_phone(contact['tel'][0]['value']) new_contact_form.type_comment('') # initialize the keyboard app keyboard = new_contact_form.keyboard # send first 15 characters, delete last character, send a space, and send all others keyboard.send(self._string[:15]) keyboard.tap_backspace() keyboard.tap_space() keyboard.send(self._string[15:]) # select special character using extended character selector keyboard.choose_extended_character('A', 8) # go back to app frame and finish this self.apps.switch_to_displayed_app() new_contact_form.tap_done() self.wait_for_condition(lambda m: len(contacts_app.contacts) == 1) contact_details = contacts_app.contacts[0].tap() output_text = contact_details.comments self.assertEqual( self._string[:14] + ' ' + self._string[15:] + 'Æ'.decode("UTF-8"), output_text)
def test_add_new_contact(self): # https://moztrap.mozilla.org/manage/case/1309/ self.contact = MockContact() contacts_app = Contacts(self.marionette) contacts_app.launch() new_contact_form = contacts_app.tap_new_contact() # Enter data into fields new_contact_form.type_given_name(self.contact['givenName']) new_contact_form.type_family_name(self.contact['familyName']) new_contact_form.type_phone(self.contact['tel']['value']) new_contact_form.type_email(self.contact['email']['value']) new_contact_form.type_street(self.contact['adr']['streetAddress']) new_contact_form.type_zip_code(self.contact['adr']['postalCode']) new_contact_form.type_city(self.contact['adr']['locality']) new_contact_form.type_country(self.contact['adr']['countryName']) new_contact_form.type_comment(self.contact['note']) new_contact_form.tap_done() self.wait_for_condition(lambda m: len(contacts_app.contacts) == 1) self.assertEqual(contacts_app.contacts[0].name, self.contact['givenName'])
def test_change_keyboard_language_settings(self): settings = Settings(self.marionette) settings.launch() keyboard_settings = settings.open_keyboard_settings() # Tap on active keyboard link select_keyboard = keyboard_settings.tap_selected_keyboards() # Tap 'add more keyboards' button add_more_keyboards = select_keyboard.tap_add_more_keyboards() # Select keyboard language, then click back to make it "stick" add_more_keyboards.select_language(u'Espa\u00F1ol') add_more_keyboards.go_back() # launch the Contacts app to verify the keyboard layout contacts_app = Contacts(self.marionette) contacts_app.launch() new_contact_form = contacts_app.tap_new_contact() new_contact_form.type_given_name('') self.wait_for_condition( lambda m: new_contact_form.keyboard.is_displayed()) # Switch to keyboard frame and switch language new_contact_form.keyboard.tap_keyboard_language_key() new_contact_form.keyboard.switch_to_keyboard() special_key = self.marionette.find_element( *self._special_key_locator).text # Checking if exists the special key - "ñ" self.assertEqual(special_key, self._expected_key)
def test_keyboard_basic(self): # Use the contacts app to enter some text contact = MockContact() contacts_app = Contacts(self.marionette) contacts_app.launch() new_contact_form = contacts_app.tap_new_contact() new_contact_form.type_phone(contact['tel']['value']) new_contact_form.type_comment('') # initialize the keyboard app keyboard = new_contact_form.keyboard # send first 15 characters, delete last character, send a space, and send all others keyboard.send(self._string[:15]) keyboard.tap_backspace() keyboard.tap_space() keyboard.send(self._string[15:]) # select special character using extended character selector # Now the menu would include the original char, so the index should +1 keyboard.choose_extended_character('A', 9) # go back to app frame and finish this self.apps.switch_to_displayed_app() new_contact_form.tap_done() self.wait_for_condition(lambda m: len(contacts_app.contacts) == 1) contact_details = contacts_app.contacts[0].tap() output_text = contact_details.comments self.assertEqual(self._string[:14] + ' ' + self._string[15:] + 'Æ'.decode("UTF-8"), output_text)
def test_change_keyboard_language_settings(self): settings = Settings(self.marionette) settings.launch() keyboard_settings = settings.open_keyboard_settings() # Tap on active keyboard link select_keyboard = keyboard_settings.tap_active_keyboard() # Tap 'add more keyboards' button add_more_keyboards = select_keyboard.tap_add_more_keyboards() # Select keyboard language add_more_keyboards.select_language('Spanish') # launch the Contacts app to verify the keyboard layout contacts_app = Contacts(self.marionette) contacts_app.launch() new_contact_form = contacts_app.tap_new_contact() new_contact_form.type_given_name('') # Switch to keyboard frame and switch language new_contact_form.keyboard.switch_to_keyboard() new_contact_form.keyboard.tap_keyboard_language_key() self.wait_for_element_displayed(*self._special_key_locator) special_key = self.marionette.find_element( *self._special_key_locator).text # Checking if exists the special key - "ñ" self.assertEqual(special_key, self._expected_key)
def test_change_keyboard_language_settings(self): settings = Settings(self.marionette) settings.launch() keyboard_settings = settings.open_keyboard_settings() # Select keyboard language keyboard_settings.select_language('spanish') # launch the Contacts app to verify the keyboard layout contacts_app = Contacts(self.marionette) contacts_app.launch() new_contact_form = contacts_app.tap_new_contact() new_contact_form.type_given_name('') # Switch to keyboard frame and switch language self.keyboard.switch_keyboard_language("es") keybframe = self.marionette.find_element( *self._select_keyb_frame_locator) self.marionette.switch_to_frame(keybframe, focus=False) self.wait_for_element_displayed(*self._special_key_locator) special_key = self.marionette.find_element( *self._special_key_locator).text # Checking if exists the special key - "ñ" self.assertEqual(special_key, self._expected_key)
def test_add_new_contact(self): # https://moztrap.mozilla.org/manage/case/1309/ self.contact = MockContact() contacts_app = Contacts(self.marionette) contacts_app.launch() new_contact_form = contacts_app.tap_new_contact() # Enter data into fields new_contact_form.type_given_name(self.contact["givenName"]) new_contact_form.type_family_name(self.contact["familyName"]) new_contact_form.type_phone(self.contact["tel"][0]["value"]) new_contact_form.type_email(self.contact["email"][0]["value"]) new_contact_form.type_street(self.contact["adr"][0]["streetAddress"]) new_contact_form.type_zip_code(self.contact["adr"][0]["postalCode"]) new_contact_form.type_city(self.contact["adr"][0]["locality"]) new_contact_form.type_country(self.contact["adr"][0]["countryName"]) new_contact_form.type_comment(self.contact["note"]) new_contact_form.tap_done() self.wait_for_condition(lambda m: len(contacts_app.contacts) == 1) self.assertEqual(contacts_app.contacts[0].name, self.contact["givenName"][0])
class TestEnduranceAddDeleteContact(GaiaEnduranceTestCase): def setUp(self): GaiaEnduranceTestCase.setUp(self) self.contacts = Contacts(self.marionette) self.contacts.launch() def test_endurance_add_delete_contact(self): self.drive(test=self.add_delete_contact, app='contacts') def add_delete_contact(self): # Add a new contact, most of this code borrowed from existing gaia-ui tests # Uses data from mock contact, except adds iteration to first name # Add new contact new_contact_form = self.contacts.tap_new_contact() # Enter data into fields contact = MockContact() contact['givenName'] = "%02dof%02d" % (self.iteration, self.iterations) new_contact_form.type_given_name(contact['givenName']) new_contact_form.type_family_name(contact['familyName']) new_contact_form.type_phone(contact['tel'][0]['value']) new_contact_form.type_email(contact['email'][0]['value']) new_contact_form.type_street(contact['adr'][0]['streetAddress']) new_contact_form.type_zip_code(contact['adr'][0]['postalCode']) new_contact_form.type_city(contact['adr'][0]['locality']) new_contact_form.type_country(contact['adr'][0]['countryName']) new_contact_form.type_comment(contact['note']) # Save new contact new_contact_form.tap_done() time.sleep(2) # Verify a new contact was added self.wait_for_condition(lambda m: len(self.contacts.contacts) == 1) # Wait a couple of seconds before deleting time.sleep(2) # Delete the contact contact_item = self.contacts.contact(contact['givenName']) contact_item_detail = contact_item.tap() contact_item_edit = contact_item_detail.tap_edit() contact_item_edit.tap_delete() contact_item_edit.tap_confirm_delete() time.sleep(1) self.assertEqual(len(self.contacts.contacts), 0, 'Should have no contacts.') # Wait a couple of seconds before the next iteration time.sleep(2)
class TestEnduranceAddDeleteContact(GaiaEnduranceTestCase): def setUp(self): GaiaEnduranceTestCase.setUp(self) self.contacts = Contacts(self.marionette) self.contacts.launch() def test_endurance_add_delete_contact(self): self.drive(test=self.add_delete_contact, app='contacts') def add_delete_contact(self): # Add a new contact, most of this code borrowed from existing gaia-ui tests # Uses data from mock contact, except adds iteration to first name # Add new contact new_contact_form = self.contacts.tap_new_contact() # Enter data into fields mock_contact = MockContact() extra_text = "-%dof%d" % (self.iteration, self.iterations) new_contact_form.type_given_name(mock_contact.givenName + extra_text) new_contact_form.type_family_name(mock_contact.familyName) new_contact_form.type_phone(mock_contact.tel['value']) new_contact_form.type_email(mock_contact.email) new_contact_form.type_street(mock_contact.street) new_contact_form.type_zip_code(mock_contact.zip) new_contact_form.type_city(mock_contact.city) new_contact_form.type_country(mock_contact.country) new_contact_form.type_comment(mock_contact.comment) # Save new contact new_contact_form.tap_done() # Verify a new contact was added self.wait_for_condition(lambda m: len(self.contacts.contacts) == 1) # Wait a couple of seconds before deleting time.sleep(2) contact = self.contacts.contact(mock_contact.givenName + extra_text) edit_contact = contact.tap().tap_edit() edit_contact.tap_delete() edit_contact.tap_confirm_delete() self.assertEqual(len(self.contacts.contacts), 0, 'Should have no contacts.') # Wait a couple of seconds before the next iteration time.sleep(2)
def test_default_contact_image(self): """ https://moztrap.mozilla.org/manage/case/14399/ """ contact = MockContact() contacts_app = Contacts(self.marionette) contacts_app.launch() new_contact_form = contacts_app.tap_new_contact() new_contact_form.type_given_name(contact['givenName']) new_contact_form.type_family_name(contact['familyName']) new_contact_form.tap_done() Wait(self.marionette).until(lambda m: len(contacts_app.contacts) == 1) first_letter = contact['givenName'][:1].upper() Wait(self.marionette).until(lambda m: contacts_app.contacts[0].image_data_group == first_letter)
class TestEnduranceAddContact(GaiaEnduranceTestCase): def setUp(self): GaiaEnduranceTestCase.setUp(self) self.contacts = Contacts(self.marionette) self.contacts.launch() def test_endurance_add_contact(self): self.drive(test=self.add_contact, app='contacts') def add_contact(self): # Add a new contact, most of this code borrowed from test_add_new_contact # Uses data from mock contact, except adds iteration to first name # Add new contact new_contact_form = self.contacts.tap_new_contact() # Enter data into fields contact = MockContact() contact['givenName'] = "%02dof%02d" % (self.iteration, self.iterations) new_contact_form.type_given_name(contact['givenName']) new_contact_form.type_family_name(contact['familyName']) new_contact_form.type_phone(contact['tel'][0]['value']) new_contact_form.type_email(contact['email'][0]['value']) new_contact_form.type_street(contact['adr'][0]['streetAddress']) new_contact_form.type_zip_code(contact['adr'][0]['postalCode']) new_contact_form.type_city(contact['adr'][0]['locality']) new_contact_form.type_country(contact['adr'][0]['countryName']) new_contact_form.type_comment(contact['note']) # Save new contact new_contact_form.tap_done() time.sleep(2) # Ensure all contacts were added if self.iteration == self.iterations: self.assertEqual(len(self.contacts.contacts), self.iterations) # Sleep between reps time.sleep(3)
class TestEnduranceAddContact(GaiaEnduranceTestCase): def setUp(self): GaiaEnduranceTestCase.setUp(self) self.contacts = Contacts(self.marionette) self.contacts.launch() def test_endurance_add_contact(self): self.drive(test=self.add_contact, app='contacts') def add_contact(self): # Add a new contact, most of this code borrowed from test_add_new_contact # Uses data from mock contact, except adds iteration to first name # Add new contact new_contact_form = self.contacts.tap_new_contact() # Enter data into fields contact = MockContact() extra_text = "-%dof%d" % (self.iteration, self.iterations) new_contact_form.type_given_name(contact.givenName + extra_text) new_contact_form.type_family_name(contact.familyName) new_contact_form.type_phone(contact.tel['value']) new_contact_form.type_email(contact.email) new_contact_form.type_street(contact.street) new_contact_form.type_zip_code(contact.zip) new_contact_form.type_city(contact.city) new_contact_form.type_country(contact.country) new_contact_form.type_comment(contact.comment) # Save new contact new_contact_form.tap_done() # Ensure all contacts were added if self.iteration == self.iterations: self.assertEqual(len(self.contacts.contacts), self.iterations) # Sleep between reps time.sleep(3)
def test_change_keyboard_language_settings(self): settings = Settings(self.marionette) settings.launch() keyboard_settings = settings.open_keyboard_settings() # Select keyboard language keyboard_settings.select_language('spanish') # launch the Contacts app to verify the keyboard layout contacts_app = Contacts(self.marionette) contacts_app.launch() new_contact_form = contacts_app.tap_new_contact() new_contact_form.type_comment('') # Switch to keyboard frame and switch language self.keyboard.switch_keyboard_language("es") keybframe = self.marionette.find_element(*self._select_keyb_frame_locator) self.marionette.switch_to_frame(keybframe, focus=False) self.wait_for_element_displayed(*self._special_key_locator) special_key = self.marionette.find_element(*self._special_key_locator).text # Checking if exists the special key - "ñ" self.assertEqual(special_key, self._expected_key)
class TestKeyboard(GaiaMtbfTestCase): _string = "aG1 2Ds3~!=@.#$^aśZîd".decode("UTF-8") def test_keyboard_basic(self): # Use the contacts app to enter some text self.contact = MockContact() self.contacts_app = Contacts(self.marionette) self.contacts_app.launch() new_contact_form = self.contacts_app.tap_new_contact() new_contact_form.type_phone(self.contact['tel']['value']) new_contact_form.type_comment('') # initialize the keyboard app keyboard = new_contact_form.keyboard # send first 15 characters, delete last character, send a space, and send all others keyboard.send(self._string[:15]) keyboard.tap_backspace() keyboard.tap_space() keyboard.send(self._string[15:]) # select special character using extended character selector keyboard.choose_extended_character('A', 9) # go back to app frame and finish this self.apps.switch_to_displayed_app() new_contact_form.tap_done() new_contact = self.contacts_app.contact(self.contact['tel']['value']) if new_contact: contact_details = new_contact.tap() output_text = contact_details.comments self.assertEqual(self._string[:14] + ' ' + self._string[15:] + 'Æ'.decode("UTF-8"), output_text) contact_details.tap_back() else: self.assertEqual(True, False)
class TestEnduranceAddEditContact(GaiaEnduranceTestCase): def setUp(self): GaiaEnduranceTestCase.setUp(self) # Remove any existing contacts self.data_layer.remove_all_contacts(60000) # Launch the Contacts app self.contacts = Contacts(self.marionette) self.contacts.launch() self.contact = MockContact() def test_endurance_add_edit_contact(self): self.drive(test=self.add_edit_contact, app='contacts') def add_edit_contact(self): # Add a new contact, most of this code borrowed from test_add_new_contact # Uses data from mock contact, except adds iteration to first name # Add new contact new_contact_form = self.contacts.tap_new_contact() original_name = self.contact.givenName extra_text = "-%dof%d" % (self.iteration, self.iterations) self.contact.givenName = self.contact.givenName + extra_text # Enter data into fields new_contact_form.type_given_name(self.contact.givenName) new_contact_form.type_family_name(self.contact.familyName) new_contact_form.type_phone(self.contact.tel['value']) new_contact_form.type_email(self.contact.email) new_contact_form.type_street(self.contact.street) new_contact_form.type_zip_code(self.contact.zip) new_contact_form.type_city(self.contact.city) new_contact_form.type_country(self.contact.country) new_contact_form.type_comment(self.contact.comment) # Save new contact new_contact_form.tap_done() # Verify a new contact was added self.wait_for_condition(lambda m: len(self.contacts.contacts) == self.iteration) # Wait a couple of seconds before editing time.sleep(2) contact_details = self.contacts.contact(self.contact.givenName).tap() edit_contact = contact_details.tap_edit() # Now we'll update the mock contact and then insert the new values into the UI self.contact.givenName = self.contact.givenName + " - edit" edit_contact.type_given_name(self.contact.givenName) contact_details = edit_contact.tap_update() contact_details.tap_back() self.assertEqual(len(self.contacts.contacts), self.iteration) contact_details = self.contacts.contact(self.contact.givenName).tap() # Now assert that the values have updated full_name = self.contact.givenName + " " + self.contact.familyName self.assertEqual(contact_details.full_name, full_name) # Back to main contacts list contact_details.tap_back() # Set mock contact name back to original, for next rep self.contact.givenName = original_name # Sleep between reps time.sleep(3)
class TestEnduranceAddEditContact(GaiaEnduranceTestCase): def setUp(self): GaiaEnduranceTestCase.setUp(self) # Remove any existing contacts self.data_layer.remove_all_contacts(60000) # Launch the Contacts app self.contacts = Contacts(self.marionette) self.contacts.launch() def test_endurance_add_edit_contact(self): self.drive(test=self.add_edit_contact, app='contacts') def add_edit_contact(self): # Add a new contact, most of this code borrowed from test_add_new_contact # Uses data from mock contact, except adds iteration to first name contact = MockContact() # Add new contact new_contact_form = self.contacts.tap_new_contact() # Enter data into fields contact['givenName'] = "%02dof%02d" % (self.iteration, self.iterations) new_contact_form.type_given_name(contact['givenName']) new_contact_form.type_family_name(contact['familyName']) new_contact_form.type_phone(contact['tel']['value']) new_contact_form.type_email(contact['email']['value']) new_contact_form.type_street(contact['adr']['streetAddress']) new_contact_form.type_zip_code(contact['adr']['postalCode']) new_contact_form.type_city(contact['adr']['locality']) new_contact_form.type_country(contact['adr']['countryName']) new_contact_form.type_comment(contact['note']) # Save new contact new_contact_form.tap_done() time.sleep(2) # Verify a new contact was added self.wait_for_condition(lambda m: len(self.contacts.contacts) == self.iteration) # Wait a couple of seconds before editing time.sleep(2) # Edit the contact contact_item = self.contacts.contact(contact['givenName']) contact_item_detail = contact_item.tap() contact_item_edit = contact_item_detail.tap_edit() # Now we'll update the mock contact and then insert the new values into the UI contact['givenName'] = '%s EDITED' %contact['givenName'] contact_item_edit.type_given_name(contact['givenName']) contact_details = contact_item_edit.tap_update() time.sleep(2) contact_details.tap_back() time.sleep(2) self.assertEqual(len(self.contacts.contacts), self.iteration) contact_details = self.contacts.contact(contact['givenName']).tap() # Now assert that the values have updated expected_name = contact['givenName'] + " " + contact['familyName'] self.assertEqual(expected_name, contact_details.full_name) # Back to main contacts list contact_details.tap_back() # Sleep between reps time.sleep(3)
class TestEnduranceAddEditContact(GaiaEnduranceTestCase): def setUp(self): GaiaEnduranceTestCase.setUp(self) # Remove any existing contacts self.data_layer.remove_all_contacts(60000) # Launch the Contacts app self.contacts = Contacts(self.marionette) self.contacts.launch() self.contact = MockContact() def test_endurance_add_edit_contact(self): self.drive(test=self.add_edit_contact, app='contacts') def add_edit_contact(self): # Add a new contact, most of this code borrowed from test_add_new_contact # Uses data from mock contact, except adds iteration to first name # Add new contact new_contact_form = self.contacts.tap_new_contact() original_name = self.contact.givenName extra_text = "-%dof%d" % (self.iteration, self.iterations) self.contact.givenName = self.contact.givenName + extra_text # Enter data into fields new_contact_form.type_given_name(self.contact.givenName) new_contact_form.type_family_name(self.contact.familyName) new_contact_form.type_phone(self.contact.tel['value']) new_contact_form.type_email(self.contact.email) new_contact_form.type_street(self.contact.street) new_contact_form.type_zip_code(self.contact.zip) new_contact_form.type_city(self.contact.city) new_contact_form.type_country(self.contact.country) new_contact_form.type_comment(self.contact.comment) # Save new contact new_contact_form.tap_done() # Verify a new contact was added self.wait_for_condition( lambda m: len(self.contacts.contacts) == self.iteration) # Wait a couple of seconds before editing time.sleep(2) contact_details = self.contacts.contact(self.contact.givenName).tap() edit_contact = contact_details.tap_edit() # Now we'll update the mock contact and then insert the new values into the UI self.contact.givenName = self.contact.givenName + " - edit" edit_contact.type_given_name(self.contact.givenName) contact_details = edit_contact.tap_update() contact_details.tap_back() self.assertEqual(len(self.contacts.contacts), self.iteration) contact_details = self.contacts.contact(self.contact.givenName).tap() # Now assert that the values have updated full_name = self.contact.givenName + " " + self.contact.familyName self.assertEqual(contact_details.full_name, full_name) # Back to main contacts list contact_details.tap_back() # Set mock contact name back to original, for next rep self.contact.givenName = original_name # Sleep between reps time.sleep(3)
class TestEnduranceAddEditContact(GaiaEnduranceTestCase): def setUp(self): GaiaEnduranceTestCase.setUp(self) # Remove any existing contacts self.data_layer.remove_all_contacts(60000) # Launch the Contacts app self.contacts = Contacts(self.marionette) self.contacts.launch() def test_endurance_add_edit_contact(self): self.drive(test=self.add_edit_contact, app='contacts') def add_edit_contact(self): # Add a new contact, most of this code borrowed from test_add_new_contact # Uses data from mock contact, except adds iteration to first name contact = MockContact() # Add new contact new_contact_form = self.contacts.tap_new_contact() # Enter data into fields contact['givenName'] = "%02dof%02d" % (self.iteration, self.iterations) new_contact_form.type_given_name(contact['givenName']) new_contact_form.type_family_name(contact['familyName']) new_contact_form.type_phone(contact['tel'][0]['value']) new_contact_form.type_email(contact['email'][0]['value']) new_contact_form.type_street(contact['adr'][0]['streetAddress']) new_contact_form.type_zip_code(contact['adr'][0]['postalCode']) new_contact_form.type_city(contact['adr'][0]['locality']) new_contact_form.type_country(contact['adr'][0]['countryName']) new_contact_form.type_comment(contact['note']) # Save new contact new_contact_form.tap_done() time.sleep(2) # Verify a new contact was added self.wait_for_condition( lambda m: len(self.contacts.contacts) == self.iteration) # Wait a couple of seconds before editing time.sleep(2) # Edit the contact contact_item = self.contacts.contact(contact['givenName']) contact_item_detail = contact_item.tap() contact_item_edit = contact_item_detail.tap_edit() # Now we'll update the mock contact and then insert the new values into the UI contact['givenName'] = '%s EDITED' % contact['givenName'] contact_item_edit.type_given_name(contact['givenName']) contact_details = contact_item_edit.tap_update() time.sleep(2) contact_details.tap_back() time.sleep(2) self.assertEqual(len(self.contacts.contacts), self.iteration) contact_details = self.contacts.contact(contact['givenName']).tap() # Now assert that the values have updated expected_name = contact['givenName'] + " " + contact['familyName'][0] self.assertEqual(expected_name, contact_details.full_name) # Back to main contacts list contact_details.tap_back() # Sleep between reps time.sleep(3)