class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) # Prepare the contact. self.contact = MockContact() self.UTILS.general.insertContact(self.contact) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def toggle_fav(self, contact_name): self.contacts.view_contact(contact_name) fav_btn = self.UTILS.element.getElement(DOM.Contacts.favourite_button, "Toggle favourite button (before tap)") fav_btn.tap() self.contacts.go_back_from_contact_details() def test_run(self): self.contacts.launch() # View the details of our contact and make him a favourite. self.UTILS.reporting.logResult("info", "<b>Setting up a contact in favourites ...</b>") self.toggle_fav(self.contact["name"]) self.UTILS.element.waitForElements(DOM.Contacts.favourites_section, "Favourites section") self.UTILS.reporting.logResult("info", "<b>Removing contact from favourites ...</b>") self.toggle_fav(self.contact['name']) self.UTILS.element.waitForNotElements(DOM.Contacts.favourites_section, "Favourites section")
class test_main(GaiaTestCase): add_fav_str = "Add as Favorite" remove_fav_str = "Remove as Favorite" def setUp(self): GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) self.contact = MockContact() self.UTILS.general.insertContact(self.contact) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.contacts.launch() # View the details of our contact and make him a favourite. self.UTILS.reporting.logResult("info", "<b>Setting up a contact in favourites ...</b>") self.contacts.view_contact(self.contact['name']) fav_btn = self.UTILS.element.getElement(DOM.Contacts.favourite_button, "Toggle favourite button (before tap)") self.UTILS.test.test(fav_btn.text == self.add_fav_str, "Toggle favourite button text is '{}'.". format(self.add_fav_str)) fav_btn.tap() fav_btn = self.UTILS.element.getElement(DOM.Contacts.favourite_button, "Toggle favourite button (after tap)") self.UTILS.test.test(fav_btn.text == self.remove_fav_str, "Toggle favourite button text is '{}'.". format(self.remove_fav_str)) self.contacts.go_back_from_contact_details() string = self.contact['givenName'] + self.contact['familyName'] favs = ("xpath", DOM.Contacts.favourites_list_xpath.format(string.upper())) self.UTILS.element.waitForElements(favs, "'" + self.contact['name'] + "' in the favourites list") screenshot = self.UTILS.debug.screenShotOnErr() self.UTILS.reporting.logResult("info", "Screenshot at this point", screenshot) self.UTILS.reporting.logResult("info", "<b>removing contact from favourites ...</b>") self.contacts.view_contact(self.contact['name']) fav_btn = self.UTILS.element.getElement(DOM.Contacts.favourite_button, "Toggle favourite button (before tap)") self.UTILS.test.test(fav_btn.text == self.remove_fav_str, "Toggle favourite button text is '{}'.". format(self.remove_fav_str)) fav_btn.tap() fav_btn = self.UTILS.element.getElement(DOM.Contacts.favourite_button, "Toggle favourite button (after tap)") self.UTILS.test.test(fav_btn.text == self.add_fav_str, "Toggle favourite button text is '{}'.". format(self.add_fav_str)) self.contacts.go_back_from_contact_details() time.sleep(1) string = self.contact['givenName'] + " " + self.contact['familyName'] favs = ("xpath", DOM.Contacts.favourites_list_xpath.format(string.upper())) self.UTILS.element.waitForNotElements(favs, "'" + self.contact['name'] + "' in the favourites list")
class test_main(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) self.contact = MockContact() self.UTILS.general.insertContact(self.contact) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.contacts.launch() # View the contact details. self.contacts.view_contact(self.contact['name']) # Press the favourites button. fav_btn = self.UTILS.element.getElement(DOM.Contacts.favourite_button, "Favourite toggle button") fav_btn.tap() # Go back to view all contacts and check this contact is listed in the # 'favourites' section. self.contacts.go_back_from_contact_details() # Check our test contact is listed in the group favourites. string = self.contact['givenName'] + self.contact['familyName'] favs = ("xpath", DOM.Contacts.favourites_list_xpath.format(string.upper())) self.UTILS.element.waitForElements(favs, "'" + self.contact['name'] + "' in the favourites list") # View the contact. self.UTILS.reporting.logResult("info", "*** Removing contact as a favourite ... ***") self.contacts.view_contact(self.contact['name']) # Press the favourites button. fav_btn = self.UTILS.element.getElement(DOM.Contacts.favourite_button, "Favourite toggle button") self.UTILS.test.test(fav_btn.text == "Remove as Favorite", "Favourite toggle button says 'Remove as Favorite' before contact is removed as a favorite.") fav_btn.tap() time.sleep(2) fav_btn = self.UTILS.element.getElement(DOM.Contacts.favourite_button, "Favourite toggle button") self.UTILS.test.test(fav_btn.text == "Add as Favorite", "Favourite toggle button says 'Add as Favorite' after contact is removed as a favorite.") # Go back to view all contacts and check this contact is listed in the # 'favourites' section. self.contacts.go_back_from_contact_details() # Check our test contact is no longer listed in the group favourites. string = self.contact['givenName'] + self.contact['familyName'] favs = ("xpath", DOM.Contacts.favourites_list_xpath.format(string.upper())) self.UTILS.element.waitForNotElements(favs, "'" + self.contact['name'] + "' in the favourites list")
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) # Prepare the contacts. self.contact_list = [MockContact() for i in range(3)] map(self.UTILS.general.insertContact, self.contact_list) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.contacts.launch() # View the details of our contact and make him a favourite. self.UTILS.reporting.logResult("info", "<b>Setting up a contact in favourites ...</b>") self.contacts.view_contact(self.contact_list[0]['name']) # Mark contact as favourite fav_btn = self.UTILS.element.getElement(DOM.Contacts.favourite_button, "Toggle favourite button (before tap)") fav_btn.tap() # Go back to all contacts list self.contacts.go_back_from_contact_details() # Check the contact is in the favourite list string = self.contact_list[0]['givenName'] + self.contact_list[0]['familyName'] favs = ("xpath", DOM.Contacts.favourites_list_xpath.format(string.upper())) self.UTILS.element.waitForElements(favs, "'" + self.contact_list[0]['name'] + "' in the favourites list") # Now check the favourites list appears first. fav_list = self.UTILS.element.getElements(("tag name", "ol"), "Contact lists") fav_id = "contacts-list-favorites" normal_ids = "contacts-list-" foundFav = False foundNormal = False for i in fav_list: if fav_id in i.get_attribute("id"): foundFav = True if normal_ids in i.get_attribute("id"): foundNormal = True break self.UTILS.test.test(foundNormal, "Found the non-favourite lists.") self.UTILS.test.test(foundFav, "Found the favourite lists before the non-favourite lists.")
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): def setUp(self): GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) # Create test contacts. self.contact = MockContact() self.UTILS.general.insertContact(self.contact) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Launch contacts app. self.contacts.launch() # View our contact. self.contacts.view_contact(self.contact['name']) # Edit our contact. self.contacts.press_edit_contact_button() # Delete our contact. self.contacts.press_delete_contact_button() # Cancel deletion. cancel_deletion = self.UTILS.element.getElement( DOM.Contacts.cancel_delete_btn, "Cancel button") cancel_deletion.tap() # Cancel contact edition self.contacts.press_cancel_edit_button() # Go back to contacts start page self.contacts.go_back_from_contact_details() # Now actually delete our contact. self.contacts.delete_contact(self.contact['name'])
class test_main(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) # Create test contacts. self.contact = MockContact() self.UTILS.general.insertContact(self.contact) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): # Launch contacts app. self.contacts.launch() # View our contact. self.contacts.view_contact(self.contact['name']) # Edit our contact. self.contacts.press_edit_contact_button() # Delete our contact. self.contacts.press_delete_contact_button() # Cancel deletion. cancel_deletion = self.UTILS.element.getElement(DOM.Contacts.cancel_delete_btn, "Cancel button") cancel_deletion.tap() # Cancel contact edition self.contacts.press_cancel_edit_button() # Go back to contacts start page self.contacts.go_back_from_contact_details() # Now actually delete our contact. self.contacts.delete_contact(self.contact['name'])
class test_main(GaiaTestCase): def setUp(self): GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) self.contact = MockContact() self.UTILS.general.insertContact(self.contact) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.contacts.launch() # View the contact details. self.contacts.view_contact(self.contact['name']) # Press the favourites button. fav_btn = self.UTILS.element.getElement(DOM.Contacts.favourite_button, "Favourite toggle button") self.UTILS.test.test(fav_btn.text == "Add as Favorite", "Favourite 'toggle' button is labelled 'Add as Favourite'.") fav_btn.tap() # Verify the favourite toggle button label changes correctly. fav_btn = self.UTILS.element.getElement(DOM.Contacts.favourite_button, "Favourite toggle button") self.UTILS.test.test(fav_btn.text == "Remove as Favorite", "Favourite 'toggle' button is labelled 'Remove as Favourite'.") # Go back to view all contacts and check this contact is listed in the # 'favourites' section. self.contacts.go_back_from_contact_details() string = self.contact['givenName'] + self.contact['familyName'] favs = ("xpath", DOM.Contacts.favourites_list_xpath.format(string.upper())) self.UTILS.element.waitForElements(favs, "'" + self.contact['name'] + "' in the favourites list")
class test_main(GaiaTestCase): def setUp(self): # Set up child objects... GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) # Prepare the contacts. self.contact_list = [MockContact() for i in range(3)] map(self.UTILS.general.insertContact, self.contact_list) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.contacts.launch() # View the details of our contact and make him a favourite. self.UTILS.reporting.logResult( "info", "<b>Setting up a contact in favourites ...</b>") self.contacts.view_contact(self.contact_list[0]['name']) # Mark contact as favourite fav_btn = self.UTILS.element.getElement( DOM.Contacts.favourite_button, "Toggle favourite button (before tap)") fav_btn.tap() # Go back to all contacts list self.contacts.go_back_from_contact_details() # Check the contact is in the favourite list string = self.contact_list[0]['givenName'] + self.contact_list[0][ 'familyName'] favs = ("xpath", DOM.Contacts.favourites_list_xpath.format(string.upper())) self.UTILS.element.waitForElements( favs, "'" + self.contact_list[0]['name'] + "' in the favourites list") # Now check the favourites list appears first. fav_list = self.UTILS.element.getElements(("tag name", "ol"), "Contact lists") fav_id = "contacts-list-favorites" normal_ids = "contacts-list-" foundFav = False foundNormal = False for i in fav_list: if fav_id in i.get_attribute("id"): foundFav = True if normal_ids in i.get_attribute("id"): foundNormal = True break self.UTILS.test.test(foundNormal, "Found the non-favourite lists.") self.UTILS.test.test( foundFav, "Found the favourite lists before the non-favourite lists.")
class test_main(GaiaTestCase): add_fav_str = "Add as Favorite" remove_fav_str = "Remove as Favorite" def setUp(self): GaiaTestCase.setUp(self) self.UTILS = UTILS(self) self.contacts = Contacts(self) self.contact = MockContact() self.UTILS.general.insertContact(self.contact) def tearDown(self): self.UTILS.reporting.reportResults() GaiaTestCase.tearDown(self) def test_run(self): self.contacts.launch() # View the details of our contact and make him a favourite. self.UTILS.reporting.logResult( "info", "<b>Setting up a contact in favourites ...</b>") self.contacts.view_contact(self.contact['name']) fav_btn = self.UTILS.element.getElement( DOM.Contacts.favourite_button, "Toggle favourite button (before tap)") self.UTILS.test.test( fav_btn.text == self.add_fav_str, "Toggle favourite button text is '{}'.".format(self.add_fav_str)) fav_btn.tap() fav_btn = self.UTILS.element.getElement( DOM.Contacts.favourite_button, "Toggle favourite button (after tap)") self.UTILS.test.test( fav_btn.text == self.remove_fav_str, "Toggle favourite button text is '{}'.".format( self.remove_fav_str)) self.contacts.go_back_from_contact_details() string = self.contact['givenName'] + self.contact['familyName'] favs = ("xpath", DOM.Contacts.favourites_list_xpath.format(string.upper())) self.UTILS.element.waitForElements( favs, "'" + self.contact['name'] + "' in the favourites list") screenshot = self.UTILS.debug.screenShotOnErr() self.UTILS.reporting.logResult("info", "Screenshot at this point", screenshot) self.UTILS.reporting.logResult( "info", "<b>removing contact from favourites ...</b>") self.contacts.view_contact(self.contact['name']) fav_btn = self.UTILS.element.getElement( DOM.Contacts.favourite_button, "Toggle favourite button (before tap)") self.UTILS.test.test( fav_btn.text == self.remove_fav_str, "Toggle favourite button text is '{}'.".format( self.remove_fav_str)) fav_btn.tap() fav_btn = self.UTILS.element.getElement( DOM.Contacts.favourite_button, "Toggle favourite button (after tap)") self.UTILS.test.test( fav_btn.text == self.add_fav_str, "Toggle favourite button text is '{}'.".format(self.add_fav_str)) self.contacts.go_back_from_contact_details() time.sleep(1) string = self.contact['givenName'] + " " + self.contact['familyName'] favs = ("xpath", DOM.Contacts.favourites_list_xpath.format(string.upper())) self.UTILS.element.waitForNotElements( favs, "'" + self.contact['name'] + "' in the favourites list")