本文整理汇总了Python中OWDTestToolkit.apps.contacts.Contacts.replace_str方法的典型用法代码示例。如果您正苦于以下问题:Python Contacts.replace_str方法的具体用法?Python Contacts.replace_str怎么用?Python Contacts.replace_str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OWDTestToolkit.apps.contacts.Contacts
的用法示例。
在下文中一共展示了Contacts.replace_str方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_main
# 需要导入模块: from OWDTestToolkit.apps.contacts import Contacts [as 别名]
# 或者: from OWDTestToolkit.apps.contacts.Contacts import replace_str [as 别名]
class test_main(GaiaTestCase):
def setUp(self):
GaiaTestCase.setUp(self)
self.UTILS = UTILS(self)
self.contacts = Contacts(self)
self.contact = MockContact()
def tearDown(self):
self.UTILS.reporting.reportResults()
GaiaTestCase.tearDown(self)
def test_run(self):
self.contacts.launch()
self.contacts.start_create_new_contact()
done_button = self.UTILS.element.getElement(DOM.Contacts.done_button, "Done button")
self.UTILS.test.test(not done_button.is_enabled(), "Done button is not enabled")
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['tel'], self.contact["tel"]["value"])
done_button = self.UTILS.element.getElement(DOM.Contacts.done_button, "Done button")
self.UTILS.test.test(done_button.is_enabled(), "Done button is not enabled")
done_button.tap()
self.contacts.view_contact(self.contact["tel"]["value"])
示例2: test_main
# 需要导入模块: from OWDTestToolkit.apps.contacts import Contacts [as 别名]
# 或者: from OWDTestToolkit.apps.contacts.Contacts import replace_str [as 别名]
class test_main(GaiaTestCase):
def setUp(self):
# Set up child objects...
GaiaTestCase.setUp(self)
self.UTILS = UTILS(self)
self.dialer = Dialer(self)
self.contacts = Contacts(self)
self.given_name = "John"
self.family_name = "Doe"
def tearDown(self):
self.UTILS.reporting.reportResults()
GaiaTestCase.tearDown(self)
def test_run(self):
self.dialer.launch()
self.dialer.enterNumber("123456789")
self.dialer.createContactFromThisNum()
contFields = self.contacts.get_contact_fields()
self.contacts.replace_str(contFields['givenName'], self.given_name)
self.contacts.replace_str(contFields['familyName'], self.family_name)
done_button = self.UTILS.element.getElement(DOM.Contacts.done_button, "Done button")
done_button.tap()
time.sleep(2)
self.UTILS.reporting.logResult('info', "displayed_app: {}".format(self.apps.displayed_app.name))
self.UTILS.test.test(self.apps.displayed_app.name == "Phone", "The dialer app is now displayed.")
示例3: test_main
# 需要导入模块: from OWDTestToolkit.apps.contacts import Contacts [as 别名]
# 或者: from OWDTestToolkit.apps.contacts.Contacts import replace_str [as 别名]
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.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom")
self.incoming_sms_num = self.UTILS.general.get_config_variable("sms_platform_numbers", "common").split(',')
def tearDown(self):
self.UTILS.reporting.reportResults()
GaiaTestCase.tearDown(self)
def test_run(self):
# Create and send a new test message.
msg_text = "Nine 123456789 numbers."
self.UTILS.messages.create_incoming_sms(self.phone_number, msg_text)
self.UTILS.statusbar.wait_for_notification_toaster_detail(msg_text, timeout=120)
title = self.UTILS.statusbar.wait_for_notification_toaster_with_titles(self.incoming_sms_num, timeout=5)
self.UTILS.statusbar.click_on_notification_title(title, DOM.Messages.frame_locator)
sms = self.messages.last_message_in_this_thread()
# Long press the embedded number link.
link = sms.find_element("tag name", "a")
link.tap()
# Select create new contact.
btn = self.UTILS.element.getElement(DOM.Messages.header_create_new_contact_btn, "Create new contact button")
btn.tap()
self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator)
contFields = self.contacts.get_contact_fields()
# Verify the number is in the number field.
self.UTILS.test.test("123456789" in contFields['tel'].get_attribute("value"),
"Our target number is in the telephone field (expected {}).".\
format(contFields['tel'].get_attribute("value")))
"""
Put the contact details into each of the fields (this method
clears each field first).
"""
self.contacts.replace_str(contFields['givenName'], "Test27000")
self.contacts.replace_str(contFields['familyName'], "Testerton")
x = self.UTILS.element.getElement(DOM.Contacts.done_button, "Done button")
x.tap()
# Wait for the contacts app to go away.
self.marionette.switch_to_frame()
self.UTILS.element.waitForNotElements(("xpath", "//iframe[contains(@src, '{}')]".\
format(DOM.Contacts.frame_locator[1])), "Contacts iframe")
# Verify that the sms app is still running.
self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator)
示例4: main
# 需要导入模块: from OWDTestToolkit.apps.contacts import Contacts [as 别名]
# 或者: from OWDTestToolkit.apps.contacts.Contacts import replace_str [as 别名]
class main(GaiaTestCase):
def setUp(self):
GaiaTestCase.setUp(self)
self.UTILS = UTILS(self)
self.loop = Loop(self)
self.contacts = Contacts(self)
self.settings = Settings(self)
self.test_contact = MockContact(givenName="QA", familyName="Automation")
self.fxa_user = self.UTILS.general.get_config_variable("fxa_user", "common")
self.fxa_pass = self.UTILS.general.get_config_variable("fxa_pass", "common")
_ = setup_translations(self)
self.expected_msg = _("This contact does not have either a phone number or an email address.")
self.contacts.launch()
self.contacts.start_create_new_contact()
cont_fields = self.contacts.get_contact_fields()
self.contacts.replace_str(cont_fields['givenName'], self.test_contact['givenName'])
self.contacts.replace_str(cont_fields['familyName'], self.test_contact['familyName'])
done_button = self.UTILS.element.getElement(DOM.Contacts.done_button, "'Done' button")
done_button.tap()
self.connect_to_network()
self.loop.initial_test_checks()
self.settings.launch()
self.settings.fxa()
self.settings.fxa_log_out()
self.apps.kill_all()
time.sleep(2)
def tearDown(self):
self.UTILS.reporting.reportResults()
GaiaTestCase.tearDown(self)
def test_run(self):
# First, login
self.loop.launch()
result = self.loop.wizard_or_login()
if result:
self.loop.firefox_login(self.fxa_user, self.fxa_pass)
self.loop.allow_permission_ffox_login()
self.UTILS.element.waitForElements(DOM.Loop.app_header, "Loop main view")
self.loop.open_address_book()
elem = (DOM.Contacts.view_all_contact_specific_contact[
0], DOM.Contacts.view_all_contact_specific_contact[1].format(self.test_contact["givenName"]))
entry = self.UTILS.element.getElement(elem, "Contact in address book")
entry.tap()
time.sleep(5)
self.marionette.switch_to_frame()
title = self.UTILS.element.getElement(DOM.GLOBAL.modal_dialog_alert_title, "Error title")
msg = self.UTILS.element.getElement(DOM.GLOBAL.modal_dialog_alert_msg, "Error message")
self.UTILS.test.test(title.text == "Firefox Hello", "Error title matches")
self.UTILS.test.test(msg.text == self.expected_msg, "Error message matches")
示例5: test_main
# 需要导入模块: from OWDTestToolkit.apps.contacts import Contacts [as 别名]
# 或者: from OWDTestToolkit.apps.contacts.Contacts import replace_str [as 别名]
class test_main(GaiaTestCase):
test_msg = "Test message."
def setUp(self):
# Set up child objects...
GaiaTestCase.setUp(self)
self.UTILS = UTILS(self)
self.messages = Messages(self)
self.contacts = Contacts(self)
self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom")
def tearDown(self):
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], "Test message.")
x = self.messages.wait_for_message()
# Tap the header to create a contact.
self.messages.header_createContact()
# Fill in some details.
contFields = self.contacts.get_contact_fields()
self.contacts.replace_str(contFields['givenName'], "Test")
self.contacts.replace_str(contFields['familyName'], "Testerton")
# Press the Done button.
x = self.UTILS.element.getElement(DOM.Contacts.done_button, "Done button")
x.tap()
# Wait for contacts app to close and return to sms app.
self.marionette.switch_to_frame()
self.UTILS.element.waitForNotElements(("xpath",
"//iframe[contains(@src, '{}')]".format(DOM.Contacts.frame_locator[1])),
"Contacts iframe")
self.UTILS.iframe.switchToFrame(*DOM.Messages.frame_locator)
# Verify the header is now the name,
x = self.UTILS.element.getElement(DOM.Messages.message_header, "Message header")
self.UTILS.test.test(x.text == "Test Testerton",
"Message header has been changed to match the contact (it was '{}').".format(x.text))
# Go back to the threads view and check the message name there too.
self.messages.go_back()
self.messages.openThread("Test Testerton")
示例6: test_main
# 需要导入模块: from OWDTestToolkit.apps.contacts import Contacts [as 别名]
# 或者: from OWDTestToolkit.apps.contacts.Contacts import replace_str [as 别名]
class test_main(GaiaTestCase):
def setUp(self):
# Set up child objects...
GaiaTestCase.setUp(self)
self.UTILS = UTILS(self)
self.dialer = Dialer(self)
self.contacts = Contacts(self)
self.Contact_1 = MockContact()
self.num = self.UTILS.general.get_config_variable("phone_number", "custom")
def tearDown(self):
self.UTILS.reporting.reportResults()
GaiaTestCase.tearDown(self)
def test_run(self):
# Enter a number in the dialer.
self.dialer.launch()
self.dialer.enterNumber(self.num)
# Press the add to contacts button, then select 'add to existing contact'.
x = self.UTILS.element.getElement(DOM.Dialer.add_to_contacts_button, "Add to contacts button")
x.tap()
x = self.UTILS.element.getElement(DOM.Dialer.create_new_contact_btn, "Create new contact button")
x.tap()
# Enter the details of the new contact.
self.UTILS.iframe.switchToFrame(*DOM.Contacts.frame_locator)
contFields = self.contacts.get_contact_fields()
self.contacts.replace_str(contFields['givenName'], self.Contact_1["givenName"])
self.contacts.replace_str(contFields['familyName'], self.Contact_1["familyName"])
done_button = self.UTILS.element.getElement(DOM.Contacts.done_button, "'Done' button")
done_button.tap()
# Verify that the contacts app is closed and we are returned to the call log.
self.marionette.switch_to_frame()
self.UTILS.element.waitForNotElements(("xpath", "//iframe[contains(@{}, '{}')]".\
format(DOM.Contacts.frame_locator[0], DOM.Contacts.frame_locator[1])),
"Contacts frame")
self.UTILS.iframe.switchToFrame(*DOM.Dialer.frame_locator)
# Verify that this contact has been created in contacts.
self.apps.kill_all()
self.contacts.launch()
self.contacts.view_contact(self.Contact_1["name"])
x = self.UTILS.debug.screenShotOnErr()
self.UTILS.reporting.logResult("info", "Final screenshot and html dump:", x)
示例7: test_main
# 需要导入模块: from OWDTestToolkit.apps.contacts import Contacts [as 别名]
# 或者: from OWDTestToolkit.apps.contacts.Contacts import replace_str [as 别名]
class test_main(GaiaTestCase):
def setUp(self):
# Set up child objects...
GaiaTestCase.setUp(self)
self.UTILS = UTILS(self)
self.dialer = Dialer(self)
self.contacts = Contacts(self)
self.test_contact = MockContact(tel={'type': 'Mobile', 'value': "665666666"})
# Generate an entry in the call log
self.dialer.launch()
self.dialer.callLog_clearAll()
self.dialer.createMultipleCallLogEntries(self.test_contact["tel"]["value"], 1)
# Create contact with image
self.UTILS.general.add_file_to_device('./tests/_resources/contact_face.jpg')
self.dialer.callLog_createContact(self.test_contact["tel"]["value"])
contFields = self.contacts.get_contact_fields()
self.contacts.replace_str(contFields['givenName'], self.test_contact["givenName"])
self.contacts.replace_str(contFields['familyName'], self.test_contact["familyName"])
self.contacts.add_gallery_image_to_contact(0)
done_button = self.UTILS.element.getElement(DOM.Contacts.done_button, "'Done' button")
done_button.tap()
time.sleep(1)
self.apps.kill_all()
time.sleep(2)
def tearDown(self):
self.UTILS.general.remove_files()
self.UTILS.reporting.reportResults()
GaiaTestCase.tearDown(self)
def test_run(self):
self.dialer.launch()
self.dialer.open_call_log()
entry = self.UTILS.element.getElement(("xpath",
DOM.Dialer.call_log_number_xpath.format(self.test_contact["tel"]["value"])),
"The call log for number {}".format(self.test_contact["tel"]["value"]))
entry.tap()
self.UTILS.iframe.switchToFrame(*DOM.Dialer.frame_locator_calling)
self.UTILS.element.waitForElements(("xpath", DOM.Dialer.outgoing_call_numberXP.format(self.test_contact["name"])),
"Outgoing call found with number matching {}".format(self.test_contact["name"]))
time.sleep(2)
self.dialer.hangUp()
示例8: test_main
# 需要导入模块: from OWDTestToolkit.apps.contacts import Contacts [as 别名]
# 或者: from OWDTestToolkit.apps.contacts.Contacts import replace_str [as 别名]
class test_main(GaiaTestCase):
def setUp(self):
# Set up child objects...
GaiaTestCase.setUp(self)
self.UTILS = UTILS(self)
self.dialer = Dialer(self)
self.contacts = Contacts(self)
_ = setup_translations(self)
self.contact_1 = MockContact()
self.phone_number = "0034" + self.UTILS.general.get_config_variable("target_call_number", "common")
# Generate an entry in the call log
self.dialer.launch()
self.dialer.callLog_clearAll()
self.dialer.createMultipleCallLogEntries(self.phone_number, 1)
def tearDown(self):
self.UTILS.reporting.reportResults()
GaiaTestCase.tearDown(self)
def test_run(self):
# Open the call log and create a contact for our number.
self.dialer.callLog_createContact(self.phone_number)
contFields = self.contacts.get_contact_fields()
self.contacts.replace_str(contFields['givenName'], self.contact_1["givenName"])
self.contacts.replace_str(contFields['familyName'], self.contact_1["familyName"])
done_button = self.UTILS.element.getElement(DOM.Contacts.done_button, "'Done' button")
done_button.tap()
# Verify that the contacts app is closed and we are returned to the call log.
self.marionette.switch_to_frame()
self.UTILS.element.waitForNotElements(("xpath", "//iframe[contains(@{}, '{}')]".
format(DOM.Contacts.frame_locator[0], DOM.Contacts.frame_locator[1])),
"Contacts frame")
self.UTILS.iframe.switchToFrame(*DOM.Dialer.frame_locator)
header = ('xpath', DOM.GLOBAL.app_head_specific.format(_("Call log")))
self.UTILS.element.waitForElements(header, "Call log header")
# Verify that this contact has been created in contacts.
self.apps.kill_all()
self.contacts.launch()
self.contacts.view_contact(self.contact_1["name"])
示例9: test_main
# 需要导入模块: from OWDTestToolkit.apps.contacts import Contacts [as 别名]
# 或者: from OWDTestToolkit.apps.contacts.Contacts import replace_str [as 别名]
class test_main(GaiaTestCase):
def setUp(self):
# Set up child objects...
GaiaTestCase.setUp(self)
self.UTILS = UTILS(self)
self.dialer = Dialer(self)
self.contacts = Contacts(self)
_ = setup_translations(self)
self.phone_number = self.UTILS.general.get_config_variable("phone_number", "custom")
self.test_contact = MockContact()
self.dialer.launch()
self.dialer.callLog_clearAll()
self.dialer.createMultipleCallLogEntries(self.phone_number, 1)
def tearDown(self):
self.UTILS.reporting.reportResults()
GaiaTestCase.tearDown(self)
def test_run(self):
self.dialer.callLog_createContact(self.phone_number)
contFields = self.contacts.get_contact_fields()
self.contacts.replace_str(contFields['givenName'], self.test_contact["givenName"])
self.contacts.replace_str(contFields['familyName'], self.test_contact["familyName"])
done_button = self.UTILS.element.getElement(DOM.Contacts.done_button, "'Done' button")
done_button.tap()
# Verify that the contacts app is closed and we are returned to the call log.
self.marionette.switch_to_frame()
self.UTILS.element.waitForNotElements(("xpath", "//iframe[contains(@{}, '{}')]".
format(DOM.Contacts.frame_locator[0], DOM.Contacts.frame_locator[1])),
"Contacts frame")
self.UTILS.iframe.switchToFrame(*DOM.Dialer.frame_locator)
header = ('xpath', DOM.GLOBAL.app_head_specific.format(_("Call log")))
self.UTILS.element.waitForElements(header, "Call log header")
# Verify that the call log now shows the contact name,
x = self.UTILS.element.getElement(("xpath", DOM.Dialer.call_log_number_xpath.format(self.phone_number)),
"The call log for phone_number {}".format(self.phone_number))
self.UTILS.test.test(self.test_contact["name"] in x.text, "Call log now shows '{}'.".
format(self.test_contact["name"]))
示例10: test_main
# 需要导入模块: from OWDTestToolkit.apps.contacts import Contacts [as 别名]
# 或者: from OWDTestToolkit.apps.contacts.Contacts import replace_str [as 别名]
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()
def tearDown(self):
self.UTILS.reporting.reportResults()
GaiaTestCase.tearDown(self)
def test_run(self):
# Launch contacts app.
self.contacts.launch()
self.contacts.start_create_new_contact()
x = self.UTILS.debug.screenShotOnErr()
self.UTILS.reporting.logResult("info", "Screenshot at this point", x)
x = self.UTILS.element.getElement(DOM.Contacts.done_button, "Done button")
self.UTILS.test.test(not x.is_enabled(), "Done button is not enabled")
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"])
self.contacts.replace_str(contFields['familyName'], self.contact["familyName"])
x = self.UTILS.debug.screenShotOnErr()
self.UTILS.reporting.logResult("info", "Screenshot at this point", x)
x = self.UTILS.element.getElement(DOM.Contacts.done_button, "Done button")
self.UTILS.test.test(x.is_enabled(), "Done button is not enabled")
x.tap()
self.contacts.view_contact(self.contact["name"])
示例11: test_main
# 需要导入模块: from OWDTestToolkit.apps.contacts import Contacts [as 别名]
# 或者: from OWDTestToolkit.apps.contacts.Contacts import replace_str [as 别名]
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()
def tearDown(self):
self.UTILS.reporting.reportResults()
GaiaTestCase.tearDown(self)
def test_run(self):
# Launch contacts app.
self.contacts.launch()
# Create the contact.
self.contacts.start_create_new_contact()
contFields = self.contacts.get_contact_fields()
self.contacts.replace_str(contFields['givenName'], self.contact["givenName"])
self.contacts.replace_str(contFields['familyName'], self.contact["familyName"])
x = self.UTILS.debug.screenShotOnErr()
self.UTILS.reporting.logResult("info", "Screenshot at this point", x)
x = self.UTILS.element.getElement(DOM.Contacts.done_button, "Done button")
x.tap()
self.contacts.view_contact(self.contact["name"])
time.sleep(1)
self.UTILS.element.waitForNotElements(("xpath", "//h2[text()='Home']"), "'Home' section.")
x = self.UTILS.debug.screenShotOnErr()
self.UTILS.reporting.logResult("info", "Screenshot at this point", x)
示例12: test_main
# 需要导入模块: from OWDTestToolkit.apps.contacts import Contacts [as 别名]
# 或者: from OWDTestToolkit.apps.contacts.Contacts import replace_str [as 别名]
class test_main(GaiaTestCase):
link = "[email protected]"
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)
示例13: test_main
# 需要导入模块: from OWDTestToolkit.apps.contacts import Contacts [as 别名]
# 或者: from OWDTestToolkit.apps.contacts.Contacts import replace_str [as 别名]
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)