Exemplo n.º 1
0
    def _get_fields_from_view_(self):
        wd = self.app.wd
        contact = Contact()
        the_whole_data = wd.find_element(By.ID, 'content').text
        contact.home_phone = re.search("H: (.*)", the_whole_data).group(1)
        contact.mobile_phone = re.search("M: (.*)", the_whole_data).group(1)
        contact.work_phone = re.search("W: (.*)", the_whole_data).group(1)
        contact.fax_phone = re.search("F: (.*)", the_whole_data).group(1)
        contact.phone2 = re.search("P: (.*)", the_whole_data).group(1)

        return contact
Exemplo n.º 2
0
    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