package test.addressbook;

import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
import static org.testng.Assert.*;

import java.util.concurrent.TimeUnit;
import java.util.Date;
import java.io.File;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.*;
import static org.openqa.selenium.OutputType.*;

public class GroupTests {
    FirefoxDriver wd;
    
    @BeforeMethod
    public void setUp() throws Exception {
        wd = new FirefoxDriver();
        wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    }
    
    @Test
    public void GroupTests() {
        wd.get("http://localhost/addressbook/group.php");
        wd.findElement(By.name("user")).click();
        wd.findElement(By.name("user")).clear();
        wd.findElement(By.name("user")).sendKeys("admin");
        wd.findElement(By.xpath("//form[@id='LoginForm']//label[.='Password:']")).click();
        wd.findElement(By.name("pass")).click();
        wd.findElement(By.name("pass")).clear();
        wd.findElement(By.name("pass")).sendKeys("secret");
        wd.findElement(By.xpath("//form[@id='LoginForm']/input[3]")).click();
        wd.findElement(By.linkText("groups")).click();
        wd.findElement(By.name("new")).click();
        wd.findElement(By.name("group_name")).click();
        wd.findElement(By.name("group_name")).clear();
        wd.findElement(By.name("group_name")).sendKeys("test1");
        wd.findElement(By.name("group_header")).click();
        wd.findElement(By.name("group_header")).click();
        wd.findElement(By.name("group_header")).clear();
        wd.findElement(By.name("group_header")).sendKeys("test2");
        wd.findElement(By.name("group_footer")).click();
        wd.findElement(By.name("group_footer")).clear();
        wd.findElement(By.name("group_footer")).sendKeys("test3");
        wd.findElement(By.name("submit")).click();
        wd.findElement(By.linkText("group page")).click();
    }
    
    @AfterMethod
    public void tearDown() {
        wd.quit();
    }
    
    public static boolean isAlertPresent(FirefoxDriver wd) {
        try {
            wd.switchTo().alert();
            return true;
        } catch (NoAlertPresentException e) {
            return false;
        }
    }
}

@@ -143,16 +143,17 @@
 s.Test;%0A
+%0A
 import s
@@ -262,16 +262,17 @@
 o.File;%0A
+%0A
 import o
@@ -438,16 +438,17 @@
 nium.*;%0A
+%0A
 import s
@@ -536,20 +536,16 @@
 ver wd;%0A
-    
 %0A    @Be
@@ -705,60 +705,8 @@
 S);%0A
-    %7D%0A    %0A    @Test%0A    public void GroupTests() %7B%0A
     
@@ -755,24 +755,75 @@
 roup.php%22);%0A
+        login();%0A    %7D%0A%0A    private void login() %7B%0A
         wd.f
@@ -1286,32 +1286,264 @@
 %5B3%5D%22)).click();%0A
+    %7D%0A%0A    @Test%0A    public void groupTest() %7B%0A        gotoGroupPage();%0A        initGroupCreation();%0A        fillGroupForm();%0A        submitGroupCreation();%0A        returnToGroupPage();%0A    %7D%0A%0A    private void returnToGroupPage() %7B%0A
         wd.findE
@@ -1567,17 +1567,21 @@
 t(%22group
-s
+ page
 %22)).clic
@@ -1577,32 +1577,80 @@
 age%22)).click();%0A
+    %7D%0A%0A    private void submitGroupCreation() %7B%0A
         wd.findE
@@ -1665,19 +1665,22 @@
 y.name(%22
-new
+submit
 %22)).clic
@@ -1676,32 +1676,74 @@
 mit%22)).click();%0A
+    %7D%0A%0A    private void fillGroupForm() %7B%0A
         wd.findE
@@ -2316,24 +2316,70 @@
 s(%22test3%22);%0A
+    %7D%0A%0A    private void initGroupCreation() %7B%0A
         wd.f
@@ -2390,38 +2390,35 @@
 lement(By.name(%22
-submit
+new
 %22)).click();%0A   
@@ -2406,32 +2406,74 @@
 new%22)).click();%0A
+    %7D%0A%0A    private void gotoGroupPage() %7B%0A
         wd.findE
@@ -2489,37 +2489,33 @@
 .linkText(%22group
- page
+s
 %22)).click();%0A   
@@ -2513,28 +2513,24 @@
 ck();%0A    %7D%0A
-    
 %0A    @AfterM
@@ -2589,20 +2589,16 @@
 ;%0A    %7D%0A
-    
 %0A    pub

test ignored