text: from git.model.group import Group
  
  
  class GroupHelper:
  
      def __init__(self, fixt):
          self.fixt = fixt
  
      def create(self, group):
          wd = self.fixt.wd
          self.open_groups_page()
          wd.find_element_by_name("new").click()
          self.fill_group_form(group)
          wd.find_element_by_name("submit").click()
          self.return_to_groups_page()
          self.group_cache = None
  
      def fill_group_form(self, group):
          self.change_field_value("group_name", group.name)
          self.change_field_value("group_header", group.header)
          self.change_field_value("group_footer", group.footer)
  
      def change_field_value(self, field_name, text):
          wd = self.fixt.wd
  
          if text is not None:
              wd.find_element_by_name(field_name).click()
              wd.find_element_by_name(field_name).clear()
              wd.find_element_by_name(field_name).send_keys(text)
  
      def open_groups_page(self):
          wd = self.fixt.wd
          if not (wd.current_url.endswith("/group.php") and len(wd.find_elements_by_name("new")) > 0):
              wd.implicitly_wait(5)
              wd.find_element_by_xpath('//a[@href="group.php"]').click()
  
      def return_to_groups_page(self):
          wd = self.fixt.wd
          wd.find_element_by_link_text("group page").click()
  
      def delete_first_group(self):
          self.delete_group_by_index(0)
  
      def delete_group_by_index(self, index):
          wd = self.fixt.wd
          self.open_groups_page()
          self.select_group_by_index(index)
          # submit deletion
          wd.find_element_by_name("delete").click()
          self.return_to_groups_page()
          self.group_cache = None
  
      def select_group_by_index(self, index):
          wd = self.fixt.wd
          wd.find_elements_by_name("selected[]")[index].click()
  
      def select_first_group(self):
          wd = self.fixt.wd
          wd.find_element_by_name("selected[]").click()
  
      def modify_first_group(self):
          self.modify_group_by_index(0)
  
      def modify_group_by_index(self, index, new_group_data):
          wd = self.fixt.wd
          self.open_groups_page()
          self.select_group_by_index(index)
          #open modification form
          wd.find_element_by_name("edit").click()
          self.fill_group_form(new_group_data)
          #submit modification
          wd.find_element_by_name("update").click()
          self.return_to_groups_page()
          self.group_cache = None
  
      def count(self):
          wd = self.fixt.wd
          self.open_groups_page()
          return len(wd.find_elements_by_name("selected[]"))
  
      group_cache = None
  
      def get_group_list(self):
          if self.group_cache is None:
              wd = self.fixt.wd
              self.open_groups_page()
              self.group_cache = []
              for element in wd.find_elements_by_css_selector('span.group'):
                  text = element.text
                  id = element.find_element_by_name('selected[]').get_attribute('value')
                  self.group_cache.append(Group(name=text, id=id))
          return list(self.group_cache)