Esempio n. 1
0
 def get_contact_info_from_edit_page(self, index):
     wd = self.app.wd
     NavigationHelper.open_home_page(self)
     self.select_contact_by_index(index)
     self.edit_contact_by_index(index)
     firstname = wd.find_element_by_name("firstname").get_attribute("value")
     lastname = wd.find_element_by_name("lastname").get_attribute("value")
     address = wd.find_element_by_name("address").get_attribute("value")
     id = wd.find_element_by_name("id").get_attribute("value")
     home = wd.find_element_by_name("home").get_attribute("value")
     mobile = wd.find_element_by_name("mobile").get_attribute("value")
     phone2 = wd.find_element_by_name("phone2").get_attribute("value")
     email = wd.find_element_by_name("email").get_attribute("value")
     email2 = wd.find_element_by_name("email2").get_attribute("value")
     email3 = wd.find_element_by_name("email3").get_attribute("value")
     return Contacts(firstname=firstname,
                     lastname=lastname,
                     address=address,
                     id=id,
                     home=home,
                     mobile=mobile,
                     phone2=phone2,
                     email=email,
                     email2=email2,
                     email3=email3)
Esempio n. 2
0
 def add_contact_to_group_by_id(self, id, group):
     wd = self.app.wd
     NavigationHelper.open_home_page(self)
     self.select_contact_by_id(id)
     self.put_group_name_for_adding(group)
     NavigationHelper.open_home_page(self)
     self.contact_cache = None
Esempio n. 3
0
 def login(self, username, password):
     wd = self.app.wd
     NavigationHelper.open_home_page(self)
     wd.find_element_by_name("user").clear()
     wd.find_element_by_name("user").send_keys(username)
     wd.find_element_by_name("pass").clear()
     wd.find_element_by_name("pass").send_keys(password)
     wd.find_element_by_xpath("//input[@value='Login']").click()
Esempio n. 4
0
 def remove_contact_from_group_by_id(self, group_with_contact_id):
     wd = self.app.wd
     NavigationHelper.open_home_page(self)
     wd.find_element_by_css_selector(
         "select[name='group'] option[value='%s']" %
         group_with_contact_id).click()
     wd.find_element_by_css_selector(
         "td[class='center'] input[type='checkbox']").click()
     wd.find_element_by_name("remove").click()
Esempio n. 5
0
 def create(self, contacts):
     wd = self.app.wd
     # init contact creation
     wd.find_element_by_link_text("add new").click()
     self.fill_contact_form(contacts)
     # submit contact creation
     wd.find_element_by_xpath("(//input[@name='submit'])[2]").click()
     NavigationHelper.open_home_page(self)
     self.contact_cache = None
Esempio n. 6
0
 def modify_contact_by_id(self, id, new_contacts_form):
     wd = self.app.wd
     # submit edit
     NavigationHelper.open_home_page(self)
     self.select_contact_by_id_and_edit(id)
     self.fill_contact_form(new_contacts_form)
     # submit contact modification
     wd.find_element_by_xpath("(//input[@name='update'])[2]").click()
     NavigationHelper.open_home_page(self)
     self.contact_cache = None
Esempio n. 7
0
 def get_contact_from_view_page(self, index):
     wd = self.app.wd
     NavigationHelper.open_home_page(self)
     self.select_contact_by_index(index)
     self.open_contact_view_by_index(index)
     text = wd.find_element_by_id("content").text
     home = re.search("H: (.*)", text).group(1)
     mobile = re.search("M: (.*)", text).group(1)
     phone2 = re.search("P: (.*)", text).group(1)
     return Contacts(home=home, mobile=mobile, phone2=phone2)
Esempio n. 8
0
 def get_contact_list(self):
     if self.contact_cache is None:
         wd = self.app.wd
         NavigationHelper.open_home_page(self)
         self.contact_cache = []
         for element in wd.find_elements_by_xpath("//tr[@name='entry']"):
             cells = element.find_elements_by_tag_name("td")
             contact_id = element.find_element_by_name(
                 "selected[]").get_attribute("value")
             lastname = element.find_element_by_xpath("./td[2]").text
             firstname = element.find_element_by_xpath("./td[3]").text
             address = element.find_element_by_xpath("./td[4]").text
             all_phones = cells[5].text
             all_emails = cells[4].text
             self.contact_cache.append(
                 Contacts(id=contact_id,
                          lastname=lastname,
                          firstname=firstname,
                          address=address,
                          all_phones_from_home_page=all_phones,
                          all_emails_from_home_page=all_emails))
     return self.contact_cache
Esempio n. 9
0
 def del_contact_by_id(self, id):
     wd = self.app.wd
     # select contact
     NavigationHelper.open_home_page(self)
     self.select_contact_by_id(id)
     wd.find_element_by_xpath("//input[@value='Delete']").click()
     try:
         WebDriverWait(wd, 1).until(EC.alert_is_present(), 'No alert')
         alert = wd.switch_to.alert
         alert.accept()
         wd.find_element_by_css_selector("div.msgbox")
     except TimeoutException:
         print("no alert")
     finally:
         NavigationHelper.open_home_page(self)
     NavigationHelper.open_home_page(self)
     self.contact_cache = None
Esempio n. 10
0
 def logout(self):
     # logout
     wd = self.app.wd
     NavigationHelper.open_home_page(self)
     wd.find_element_by_link_text("Logout").click()
     wd.find_element_by_name("user")