text: # -*- coding: utf-8 -*-
  from selenium import webdriver
  from selenium.webdriver.common.by import By
  from selenium.webdriver.common.keys import Keys
  from selenium.webdriver.support.ui import Select
  from selenium.common.exceptions import NoSuchElementException
  from selenium.common.exceptions import NoAlertPresentException
  import unittest
  
  class TestAddGroup(unittest.TestCase):
      def setUp(self):
          self.wd = webdriver.Firefox()        self.wd.implicitly_wait(30)
  
      def test_add_group(self):
          wd = self.wd
          # open home page
          wd.get("http://localhost/group.php")
          # login
          wd.find_element_by_name("user").clear()
          wd.find_element_by_name("user").send_keys("admin")
          wd.find_element_by_id("LoginForm").click()
          wd.find_element_by_name("pass").click()
          wd.find_element_by_name("pass").clear()
          wd.find_element_by_name("pass").send_keys("secret")
          wd.find_element_by_xpath(u"//input[@value='Login']").click()
          # open group page
          wd.find_element_by_link_text("groups").click()
          # init group creation
          wd.find_element_by_name("new").click()
          # fill group form
          wd.find_element_by_name("group_name").click()
          wd.find_element_by_name("group_name").clear()
          wd.find_element_by_name("group_name").send_keys("qwert")
          wd.find_element_by_name("group_header").click()
          wd.find_element_by_name("group_header").clear()
          wd.find_element_by_name("group_header").send_keys("qwert")
          wd.find_element_by_name("group_footer").click()
          wd.find_element_by_name("group_footer").clear()
          wd.find_element_by_name("group_footer").send_keys("qwert")
          # submit group creation
          wd.find_element_by_name("submit").click()
          # return from group page
          wd.find_element_by_link_text("group page").click()
          # logout
          wd.find_element_by_link_text("Logout").click()
      
      def is_element_present(self, how, what):
          try: self.wd.find_element(by=how, value=what)
          except NoSuchElementException as e: return False
          return True
      
      def is_alert_present(self):
          try: self.wd.switch_to_alert()
          except NoAlertPresentException as e: return False
          return True
      
  
      def tearDown(self):
          self.wd.quit()
  
  if __name__ == "__main__":
      unittest.main()
  