text: from selenium.webdriver.support.ui import Select
  import time
  
  
  class ContactHelper:
  
      def __init__(self, app):
          self.app = app
  
      def open_add_contact(self):
          # переходим в раздел добавления контакта
          wd = self.app.wd
          wd.find_element_by_link_text("add new").click()
  
      def fill_contact_form(self, group):
          wd = self.app.wd
          self.open_add_contact()
          # заполняем поля
          wd.find_element_by_name("firstname").click()
          wd.find_element_by_name("firstname").clear()
          wd.find_element_by_name("firstname").send_keys(group.first_name)
          wd.find_element_by_name("middlename").click()
          wd.find_element_by_name("middlename").clear()
          wd.find_element_by_name("middlename").send_keys(group.middle_name)
          wd.find_element_by_name("lastname").click()
          wd.find_element_by_name("lastname").clear()
          wd.find_element_by_name("lastname").send_keys(group.last_name)
          wd.find_element_by_name("nickname").click()
          wd.find_element_by_name("nickname").clear()
          wd.find_element_by_name("nickname").send_keys(group.user_nick)
          wd.find_element_by_name("title").click()
          wd.find_element_by_name("title").clear()
          wd.find_element_by_name("title").send_keys(group.user_title)
          wd.find_element_by_name("company").click()
          wd.find_element_by_name("company").clear()
          wd.find_element_by_name("company").send_keys(group.user_company)
          wd.find_element_by_name("address").click()
          wd.find_element_by_name("address").clear()
          wd.find_element_by_name("address").send_keys(group.user_adress)
          wd.find_element_by_name("home").click()
          wd.find_element_by_name("home").clear()
          wd.find_element_by_name("home").send_keys(group.user_home)
          wd.find_element_by_name("mobile").click()
          wd.find_element_by_name("mobile").clear()
          wd.find_element_by_name("mobile").send_keys(group.user_mob)
          wd.find_element_by_name("email").click()
          wd.find_element_by_name("email").clear()
          wd.find_element_by_name("email").send_keys(group.user_email)
          wd.find_element_by_name("bday").click()
          Select(wd.find_element_by_name("bday")).select_by_visible_text(group.user_bday)
          wd.find_element_by_xpath("//option[@value='17']").click()
          wd.find_element_by_name("bmonth").click()
          Select(wd.find_element_by_name("bmonth")).select_by_visible_text(group.user_bmonth)
          wd.find_element_by_xpath("//option[@value='October']").click()
          wd.find_element_by_name("byear").click()
          wd.find_element_by_name("byear").clear()
          wd.find_element_by_name("byear").send_keys(group.user_byear)
          # wd.find_element_by_name("new_group").click()
          # Select(wd.find_element_by_name("new_group")).select_by_visible_text(group.user_group)
          # wd.find_element_by_xpath("(//option[@value='10'])[3]").click()
          wd.find_element_by_name("address2").click()
          wd.find_element_by_name("address2").clear()
          wd.find_element_by_name("address2").send_keys(group.user_addr2)
          wd.find_element_by_name("phone2").click()
          wd.find_element_by_name("phone2").clear()
          wd.find_element_by_name("phone2").send_keys(group.user_phone2)
          wd.find_element_by_name("notes").click()
          wd.find_element_by_name("notes").clear()
          wd.find_element_by_name("notes").send_keys(group.user_note)
          wd.find_element_by_xpath("(//input[@name='submit'])[2]").click()
          self.return_to_contact()
          time.sleep(5)
  
      def return_to_contact(self):
          # переходим на форму списка контактов - убеждаемся, что контакт создался
          wd = self.app.wd
          wd.find_element_by_link_text("home").click()