def get_contact_data(self):
     wd = self.app.wd
     text = wd.find_element_by_id("content").text
     home_phone = re.search("H: (.*)", text).group(1)
     work_phone = re.search("W: (.*)", text).group(1)
     mobile_phone = re.search("M: (.*)", text).group(1)
     secondary_phone = re.search("P: (.*)", text).group(1)
     new_contact = Contact()
     new_contact.set_phones(home=home_phone, mobile=mobile_phone, work=work_phone, second_phone=secondary_phone,
                            fax=None)
     return new_contact
Exemplo n.º 2
0
def test_check_all_contacts_on_main_page(app, db):
    if len(db.get_contact_list()) == 0:
        contact = Contact(firstname="Ann", middlename="AT", lastname="Arner", nickname="Tee")
        contact.set_phones(home="3321123", mobile="+792938232", work="44142221", second_phone="+791229313", fax="2123")
        app.contact.create(contact)
    contacts_from_main_page = app.contact.get_all_contacts()
    contacts_from_db = db.get_contact_list()
    for db_contact in contacts_from_db:
        value_found = False
        for web_contact in contacts_from_main_page:
            if db_contact.id == web_contact.id:
                value_found = True
                check_all_values_on_home_page(web_contact, db_contact)
                break
        if not value_found:
            raise ValueError('Contact with id %s not found on main page' % str(db_contact.id))
Exemplo n.º 3
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)
def test_update_some_contact(app, db, check_ui):
    app.contact.set_default_contacts_view_on_contact_page()
    if len(db.get_contact_list()) == 0:
        contact = Contact(firstname="Ann", middlename="AT", lastname="Arner", nickname="Tee")
        app.contact.create(contact)
    old_contacts = db.get_contact_list()
    contact = random.choice(old_contacts)
    app.contact.update_contact_from_list_by_id(contact.id, None)
    # Count contacts
    new_contact = Contact("", "", "", "")
    new_contact.id = contact.id
    # Check contacts list
    old_contacts.remove(contact)
    old_contacts.append(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)
def test_update_last_contact(app, db, check_ui):
    # Prepare before test
    app.contact.prepare_contact_test_suite()
    # Prepare old contact data
    contact = Contact(firstname="Leo", middlename="LLL", lastname="Lemon", 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="Anny", middlename="AA", lastname="Arnert", nickname="TaT")
    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="+111331212")
    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="Tee")
    second_contact = Contact(firstname="Don", middlename="JD", lastname="Doe", nickname="Jay")
    # Create contacts
    app.contact.create(contact)
    app.contact.create(first_contact)
    app.contact.create(second_contact)
    old_contacts = app.contact.get_all_contacts()
    # Update contact
    new_contact.id = old_contacts[2].id
    app.contact.update_contact_from_list(3, new_contact)
    # Check contacts list
    old_contacts[2] = 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)
Exemplo n.º 6
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