class test_main(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) self.test_contact = MockContact() self.UTILS.general.insertContact(self.test_contact) self.email_1 = "*****@*****.**" self.email_2 = "*****@*****.**" def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.contacts.launch() self.contacts.view_contact(self.test_contact['name']) self.contacts.press_edit_contact_button() # Count the current email addresses. orig_count = self.contacts.count_email_addresses_while_editing() # Add a few email addresses. self.contacts.add_another_email_address(self.email_1) self.contacts.add_another_email_address(self.email_2) # Get the new count and check it's been updated new_count = self.contacts.count_email_addresses_while_editing() self.UTILS.test.test(new_count == orig_count + 2, "After adding two email, there are three") update_btn = self.UTILS.element.getElement(DOM.Contacts.edit_update_button, "Update button") update_btn.tap() self.contacts.go_back_from_contact_details() self.contacts.view_contact(self.test_contact['name']) # Count the email fields. emails_elements = self.UTILS.element.getElements(DOM.Contacts.email_address_list, "Email addresses") emails = [elem.find_element(*('css selector', 'button b')).text for elem in emails_elements] self.UTILS.test.test(self.email_1 in emails, "Email 1 has been saved") self.UTILS.test.test(self.email_2 in emails, "Email 2 has been saved")
class test_main(GaiaTestCase): link = "*****@*****.**" test_msg = "Test " + link + " this." def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.contacts = Contacts(self) # Insert a contact without email addresses self.UTILS.general.add_file_to_device('./tests/_resources/contact_face.jpg') self.contact = MockContact(email={'type': 'Personal', 'value': ''}) self.UTILS.general.insertContact(self.contact) # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number) def tearDown(self): self.UTILS.general.remove_files() self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Launch messages app. self.messages.launch() # Create and send a new test message. self.messages.create_and_send_sms([self.phone_number], self.test_msg) """ Wait for the last message in this thread to be a 'received' one and click the link. """ x = self.messages.wait_for_message() self.UTILS.test.test(x, "Received a message.", True) a = x.find_element("tag name", "a") a.tap() # Press 'add to existing contact' button. w = self.UTILS.element.getElement(DOM.Messages.header_add_to_contact_btn, "Add to existing contact button") w.tap() # Switch to Contacts app. time.sleep(2) self.marionette.switch_to_frame() self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator) # Select the contact. prepopulated_contact = (DOM.Contacts.view_all_contact_specific_contact[0], DOM.Contacts.view_all_contact_specific_contact[1].format("OWD")) contact = self.UTILS.element.getElement(prepopulated_contact, "Search item") contact.tap() # Fill out all the other details. contFields = self.contacts.get_contact_fields() """ Put the contact details into each of the fields (this method clears each field first). """ self.contacts.replace_str(contFields['givenName'], self.contact["givenName"] + "bis") self.contacts.replace_str(contFields['familyName'], self.contact["familyName"] + "bis") self.contacts.replace_str(contFields['tel'], self.contact["tel"]["value"] + "bis") self.contacts.replace_str(contFields['street'], self.contact["addr"]["streetAddress"] + "bis") self.contacts.replace_str(contFields['zip'], self.contact["addr"]["postalCode"] + "bis") self.contacts.replace_str(contFields['city'], self.contact["addr"]["locality"] + "bis") self.contacts.replace_str(contFields['country'], self.contact["addr"]["countryName"] + "bis") self.contacts.add_gallery_image_to_contact(0) # Add another email address. self.contacts.add_another_email_address(self.contact["email"]["value"]) # Press the Done button. done_button = self.UTILS.element.getElement(DOM.Contacts.done_button, "'Done' button") done_button.tap() # Check that the contacts iframe is now gone. self.marionette.switch_to_frame() self.UTILS.element.waitForNotElements(("xpath", "//iframe[contains(@src,'contacts')]"), "Contact app iframe") # Now return to the SMS app. self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator)
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.contacts = Contacts(self) self.email = Email(self) self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom") self.emailAddy = self.UTILS.general.get_config_variable("gmail_1_email", "common") self.emailE = self.UTILS.general.get_config_variable("gmail_2_email", "common") self.emailP = self.UTILS.general.get_config_variable("gmail_2_pass", "common") self.emailU = self.UTILS.general.get_config_variable("gmail_2_user", "common") self.UTILS.general.add_file_to_device('./tests/_resources/contact_face.jpg') self.test_msg = "Test message." self.cont = MockContact() self.data_layer.delete_all_sms() def tearDown(self): self.UTILS.general.remove_files() self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.connect_to_network() self.email.launch() self.email.setup_account(self.emailU, self.emailE, self.emailP) self.messages.launch() # Create and send a new test message. self.messages.create_and_send_sms([self.phone_number], "Hello {} old bean.".format(self.emailAddy)) send_time = self.messages.last_sent_message_timestamp() x = self.messages.wait_for_message(send_time=send_time) link = x.find_element("tag name", "a") link.tap() # Click 'create new contact'. self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator) x = self.UTILS.element.getElement(DOM.Messages.header_create_new_contact_btn, "Create new contact button") x.tap() # Verify that the email is in the email field. self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator) x = self.UTILS.element.getElement(DOM.Contacts.email_field, "Email field") x_txt = x.get_attribute("value") self.UTILS.test.test(x_txt == self.emailAddy, "Email is '{}' (expected '{}')".format(x_txt, self.emailAddy)) # Put the contact details into each of the fields (this method # clears each field first). self._changeField('givenName', self.cont["givenName"]) self._changeField('familyName', self.cont["familyName"]) self._changeField('tel', self.cont["tel"]["value"]) self._changeField('street', self.cont["addr"]["streetAddress"]) self._changeField('zip', self.cont["addr"]["postalCode"]) self._changeField('city', self.cont["addr"]["locality"]) self._changeField('country', self.cont["addr"]["countryName"]) # Add another email address. self.contacts.add_another_email_address(self.cont["email"]["value"]) done_button = self.UTILS.element.getElement(DOM.Contacts.done_button, "'Done' button") done_button.tap() self.marionette.switch_to_frame() self.UTILS.element.waitForNotElements(("xpath", "//iframe[contains(@src,'contacts')]"), "Contact app iframe") # Now return to the SMS app. self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator) def _changeField(self, p_field, p_valObj): # To try and get around marionette issues I'm resetting Marionette every time here. self.UTILS.general.checkMarionetteOK() self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator) contFields = self.contacts.get_contact_fields() self.contacts.replace_str(contFields[p_field], p_valObj)
class test_main(GaiaTestCase): link = "*****@*****.**" test_msg = "Test " + link + " this." def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.messages = Messages(self) self.contacts = Contacts(self) # Insert a contact without email addresses self.UTILS.general.add_file_to_device( './tests/_resources/contact_face.jpg') self.contact = MockContact(email={'type': 'Personal', 'value': ''}) self.UTILS.general.insertContact(self.contact) # Establish which phone number to use. self.phone_number = self.UTILS.general.get_config_variable( "phone_number", "custom") self.UTILS.reporting.logComment("Sending sms to telephone number " + self.phone_number) def tearDown(self): self.UTILS.general.remove_files() self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Launch messages app. self.messages.launch() # Create and send a new test message. self.messages.create_and_send_sms([self.phone_number], self.test_msg) """ Wait for the last message in this thread to be a 'received' one and click the link. """ x = self.messages.wait_for_message() self.UTILS.test.test(x, "Received a message.", True) a = x.find_element("tag name", "a") a.tap() # Press 'add to existing contact' button. w = self.UTILS.element.getElement( DOM.Messages.header_add_to_contact_btn, "Add to existing contact button") w.tap() # Switch to Contacts app. time.sleep(2) self.marionette.switch_to_frame() self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator) # Select the contact. prepopulated_contact = ( DOM.Contacts.view_all_contact_specific_contact[0], DOM.Contacts.view_all_contact_specific_contact[1].format("OWD")) contact = self.UTILS.element.getElement(prepopulated_contact, "Search item") contact.tap() # Fill out all the other details. contFields = self.contacts.get_contact_fields() """ Put the contact details into each of the fields (this method clears each field first). """ self.contacts.replace_str(contFields['givenName'], self.contact["givenName"] + "bis") self.contacts.replace_str(contFields['familyName'], self.contact["familyName"] + "bis") self.contacts.replace_str(contFields['tel'], self.contact["tel"]["value"] + "bis") self.contacts.replace_str( contFields['street'], self.contact["addr"]["streetAddress"] + "bis") self.contacts.replace_str(contFields['zip'], self.contact["addr"]["postalCode"] + "bis") self.contacts.replace_str(contFields['city'], self.contact["addr"]["locality"] + "bis") self.contacts.replace_str(contFields['country'], self.contact["addr"]["countryName"] + "bis") self.contacts.add_gallery_image_to_contact(0) # Add another email address. self.contacts.add_another_email_address(self.contact["email"]["value"]) # Press the Done button. done_button = self.UTILS.element.getElement(DOM.Contacts.done_button, "'Done' button") done_button.tap() # Check that the contacts iframe is now gone. self.marionette.switch_to_frame() self.UTILS.element.waitForNotElements( ("xpath", "//iframe[contains(@src,'contacts')]"), "Contact app iframe") # Now return to the SMS app. self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator)