# -*- coding: utf-8 -*-
from selenium.webdriver.firefox.webdriver import WebDriver
import unittest


def is_alert_present(wd):
    try:
        wd.switch_to_alert().text
        return True
    except:
        return False


class test_add_group(unittest.TestCase):
    def setUp(self):
        self.wd = WebDriver(capabilities={"marionette": False})
        self.wd.implicitly_wait(60)
    
    def test_test_add_group(self):
        success = True
        wd = self.wd
        wd.get("http://192.168.10.214/addressbook/index.php")
        wd.find_element_by_name("user").send_keys("admin")
        wd.find_element_by_name("pass").send_keys("secret")
        wd.find_element_by_xpath(".//*[@id='LoginForm']/input[@value='Login']").click()
        wd.find_element_by_link_text("groups").click()
        wd.find_element_by_name("new").click()
        wd.find_element_by_name("group_name").send_keys("python_test_group")
        wd.find_element_by_name("group_header").send_keys("python_test_group_Logo")
        wd.find_element_by_name("group_footer").send_keys("python_test_group_Comment")
        wd.find_element_by_name("submit").click()
        wd.find_element_by_link_text("group page").click()
        wd.find_element_by_link_text("Logout").click()
        self.assertTrue(success)
    
    def tearDown(self):
        self.wd.quit()

if __name__ == '__main__':
    unittest.main()

@@ -380,20 +380,16 @@
 ait(60)%0A
-    
 %0A    def
@@ -393,78 +393,33 @@
 def 
-test_test_add_group(self):%0A        success = True%0A        wd = self.wd
+open_home_page(self, wd):
 %0A   
@@ -476,16 +476,42 @@
 ex.php%22)
+%0A%0A    def login(self, wd):
 %0A       
@@ -701,32 +701,69 @@
 ogin'%5D%22).click()
+%0A%0A    def open_groups_page(self, wd):
 %0A        wd.find
@@ -793,32 +793,65 @@
 groups%22).click()
+%0A%0A    def create_group(self, wd):
 %0A        wd.find
@@ -1171,32 +1171,73 @@
 submit%22).click()
+%0A%0A    def return_to_group_page(self, wd):
 %0A        wd.find
@@ -1271,32 +1271,59 @@
 p page%22).click()
+%0A%0A    def logout(self, wd):
 %0A        wd.find
@@ -1353,32 +1353,293 @@
 Logout%22).click()
+%0A%0A    def test_test_add_group(self):%0A        success = True%0A        wd = self.wd%0A        self.open_home_page(wd)%0A        self.login(wd)%0A        self.open_groups_page(wd)%0A        self.create_group(wd)%0A        self.return_to_group_page(wd)%0A        self.logout(wd)
 %0A        self.as
@@ -1656,20 +1656,16 @@
 uccess)%0A
-    
 %0A    def

separate to methods