def test_delete_some_contact(app): # Get list of existing contacts contact_to_delete = Contact(first_name="first_name1", last_name="last_name1") contacts_list_len = app.contact_page.count() # Check the lenght of contact list if contacts_list_len == 0: app.contact_page.create(contact_to_delete) contacts_list = app.contact_page.get_list() index = randrange(len(contacts_list)) # Find first contact in list and save its ID contact_to_delete.id = contacts_list[index].id contact_to_delete.first_name = contacts_list[index].first_name contact_to_delete.first_name = contacts_list[index].last_name # Delete first contact from list app.contact_page.delete_by_index(index) # Assert result assert len(contacts_list) - 1 == app.contact_page.count( ) # check new length of contacts list # Get updated contacts list contacts_list = app.contact_page.get_list() assert contact_to_delete not in contacts_list # check for deleted element existed
def _get_fields_from_edit_(self): wd = self.app.wd contact = Contact() # GET main fields contact.id = self._get_field_value_(By.NAME, "id") contact.first_name = self._get_field_value_(By.NAME, "firstname") contact.middle_name = self._get_field_value_(By.NAME, "middlename") contact.last_name = self._get_field_value_(By.NAME, "lastname") contact.nickname = self._get_field_value_(By.NAME, "nickname") # GET companies fields contact.company = self._get_field_value_(By.NAME, "company") contact.title = self._get_field_value_(By.NAME, "title") contact.address = self._get_field_value_(By.NAME, "address") # GET phones fields contact.home_phone = self._get_field_value_(By.NAME, "home") contact.mobile_phone = self._get_field_value_(By.NAME, "mobile") contact.work_phone = self._get_field_value_(By.NAME, "work") contact.fax_phone = self._get_field_value_(By.NAME, "fax") # GET email fields contact.email = self._get_field_value_(By.NAME, "email") contact.email2 = self._get_field_value_(By.NAME, "email2") contact.email3 = self._get_field_value_(By.NAME, "email3") contact.homepage = self._get_field_value_(By.NAME, "homepage") # TODO do some stuff for get value of selector # GET birthday date field # if contact.birth_date is not date.min and contact.birth_date is not None: # b_day = contact.birth_date.day.__str__() # b_month = contact.birth_date.strftime("%B") # b_year = contact.birth_date.year.__int__() # else: # b_day = None # b_month = None # = None # self._set_select_value_(By.XPATH, "//div[@id='content']/form/select[1]", b_day) # self._set_select_value_(By.XPATH, "//div[@id='content']/form/select[2]", b_month) # b_year = self._get_field_value_(By.NAME, "byear", b_year) # contact.birth_date = date(b_year,b_month,b_day) # GET anniversary date field # if contact.anniversary_date is not date.min and contact.anniversary_date is not None: # a_day = contact.anniversary_date.day.__str__() # a_month = contact.anniversary_date.strftime("%B") # a_year = contact.anniversary_date.year.__int__() # else: # a_day = None # a_month = None # a_year = None # self._set_select_value_(By.XPATH, "//div[@id='content']/form/select[3]", a_day) # self._set_select_value_(By.XPATH, "//div[@id='content']/form/select[4]", a_month) # a_year = self._get_field_value_(By.NAME, "ayear") # contact.birth_date = date(a_year, a_month, a_day) # GET address fields contact.address2 = self._get_field_value_(By.NAME, "address2") contact.phone2 = self._get_field_value_(By.NAME, "phone2") contact.notes = self._get_field_value_(By.NAME, "notes") # Return founded fields return contact