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)