コード例 #1
0
 def get_all_contacts(self):
     self.return_to_home_page()
     # Check current group view
     current_view = self.contacts_page.get_current_group_view()
     # If group view has been changed, reset contact_cache
     if current_view != self.last_view:
         self.contact_cache = None
         self.last_view = current_view
     # Fill contact cache if it has not been filled before
     if self.contact_cache is None:
         self.return_to_home_page()
         self.contact_cache = []
         for element in self.contacts_page.get_all_contacts():
             # Get last name
             lastname = element.find_element_by_xpath("td[2]").text
             # Get first name
             firstname = element.find_element_by_xpath("td[3]").text
             # Get address
             address = element.find_element_by_xpath("td[4]").text
             # Get all emails
             all_emails = element.find_element_by_xpath("td[5]")
             email_list = []
             for one_href in all_emails.find_elements_by_xpath("a"):
                 email_list.append(one_href.text)
             # Get all phones
             all_phones = element.find_element_by_xpath("td[6]").text
             # Get id
             contact_id = element.find_element_by_name("selected[]").get_attribute("value")
             temp_contact = Contact(firstname=firstname, lastname=lastname, id=contact_id)
             temp_contact.set_address(address=address)
             temp_contact.set_all_phones_from_home_page(all_phones_from_home_page=all_phones)
             temp_contact.set_all_emails_from_home_page(all_emails_from_home_page=email_list)
             self.contact_cache.append(temp_contact)
     return list(self.contact_cache)
コード例 #2
0
def test_update_contact_from_details_page(app, db, check_ui):
    # Prepare before test
    app.contact.prepare_contact_test_suite()
    # Prepare old contact data
    contact = Contact(firstname="Ann", middlename="AT", lastname="Arner", nickname="Tee")
    contact.set_company_data(title="MegaMailGroutOfAllWorld", company="MegaMailGroupOfAllWorldCorporation")
    contact.set_address(address="somewhere beyond the sea")
    contact.set_emails(first="*****@*****.**",
                       second="*****@*****.**", third="*****@*****.**")
    contact.set_homepage("www.somewherebeyondthesea.com")
    contact.set_phones(home="112223366", mobile="+7(000)9999911111222", work="44444433", fax="2300011",
                       second_phone="+123331212")
    contact.set_second_info(address="World 36", notes="She is my friend")
    contact.set_birthday(day="4", month="4", year="1987")
    contact.set_anniversary(day="31", month="7", year="2010")
    # Create contacts
    app.contact.create(contact)
    old_contacts = app.contact.get_all_contacts()
    # Update contact
    app.contact.update_contact_from_details_page(1, None)
    new_contact = Contact("", "", "", "")
    new_contact.id = old_contacts[0].id
    # Check contacts list
    old_contacts[0] = new_contact
    new_contacts = db.get_contact_list()
    app.contact.check_if_contacts_are_equal(old_contacts, new_contacts)
    if check_ui:
        new_contacts = app.contact.get_all_contacts()
        app.contact.check_if_contacts_are_equal(old_contacts, new_contacts)
コード例 #3
0
 def get_data_from_fields(self):
     contact_id = self.get_string_field_value("id")
     firstname = self.get_string_field_value("firstname")
     middlename = self.get_string_field_value("middlename")
     lastname = self.get_string_field_value("lastname")
     nickname = self.get_string_field_value("nickname")
     company = self.get_string_field_value("company")
     title = self.get_string_field_value("title")
     address = self.get_string_field_value("address")
     home = self.get_string_field_value("home")
     mobile = self.get_string_field_value("mobile")
     work = self.get_string_field_value("work")
     fax = self.get_string_field_value("fax")
     email = self.get_string_field_value("email")
     email2 = self.get_string_field_value("email2")
     email3 = self.get_string_field_value("email3")
     homepage = self.get_string_field_value("homepage")
     address2 = self.get_string_field_value("address2")
     phone2 = self.get_string_field_value("phone2")
     notes = self.get_string_field_value("notes")
     contact_data = Contact(firstname=firstname, middlename=middlename, lastname=lastname,
                            nickname=nickname, id=contact_id)
     contact_data.set_company_data(title=title, company=company)
     contact_data.set_address(address=address)
     contact_data.set_second_info(address=address2, notes=notes)
     contact_data.set_emails(first=email, second=email2, third=email3)
     contact_data.set_homepage(homepage)
     contact_data.set_phones(home=home, mobile=mobile, work=work, fax=fax, second_phone=phone2)
     return contact_data
コード例 #4
0
def test_update_middle_contact(app, db, check_ui):
    # Prepare before test
    app.contact.prepare_contact_test_suite()
    # Prepare old contact data
    contact = Contact(firstname="Dave", middlename="JD", lastname="Doe", nickname="Tee")
    contact.set_company_data(title="MegaMailGroutOfAllWorld", company="MegaMailGroupOfAllWorldCorporation")
    contact.set_address(address="somewhere beyond the sea")
    contact.set_emails(first="*****@*****.**",
                       second="*****@*****.**", third="*****@*****.**")
    contact.set_homepage("www.somewherebeyondthesea.com")
    contact.set_phones(home="112223366", mobile="+7(000)9999911111222", work="44444433", fax="2300011",
                       second_phone="+123331212")
    contact.set_second_info(address="World 36", notes="She is my friend")
    contact.set_birthday(day="4", month="4", year="1987")
    contact.set_anniversary(day="31", month="7", year="2010")
    # Prepare new contact data
    new_contact = Contact(firstname="QAnny", middlename="QAA", lastname="QArnert", nickname="QTaT")
    new_contact.set_company_data(title="MegaMailGroutOfAllWorld2", company="MegaMailGroupOfAllWorldCorporation2")
    new_contact.set_address(address="somewhere beyond the sea2")
    new_contact.set_emails(first="*****@*****.**",
                           second="*****@*****.**", third="*****@*****.**")
    new_contact.set_homepage("www.somewherebeyondthesea2.com")
    new_contact.set_phones(home="112223377", mobile="+7(000)9999911111777", work="44444477", fax="2300077",
                           second_phone="+1233399")
    new_contact.set_second_info(address="World 77", notes="She is my best friend")
    new_contact.set_birthday(day="5", month="5", year="1986")
    new_contact.set_anniversary(day="12", month="3", year="2011")
    # Prepare other contacts
    first_contact = Contact(firstname="Ann", middlename="AT", lastname="Arner", nickname="Jay")
    third_contact = Contact(firstname="Leo", middlename="LLL", lastname="Lemon", nickname="Lem")
    # Create contacts
    app.contact.create(contact)
    app.contact.create(first_contact)
    app.contact.create(third_contact)
    old_contacts = app.contact.get_all_contacts()
    # Update contact
    new_contact.id = old_contacts[1].id
    app.contact.update_contact_from_list(2, new_contact)
    # Check contacts list
    old_contacts[1] = new_contact
    new_contacts = db.get_contact_list()
    app.contact.check_if_contacts_are_equal(old_contacts, new_contacts)
    if check_ui:
        new_contacts = app.contact.get_all_contacts()
        app.contact.check_if_contacts_are_equal(old_contacts, new_contacts)