Statistics
| Branch: | Revision:

m2u-upass-admin / test / selenium / AnotherTestWithSeleniumBuilder.java @ 145:759e0254d785

History | View | Annotate | Download (3.6 KB)

1 119:6973002711ef hadi
package selenium;
2
3
import static org.junit.Assert.assertFalse;
4
import static org.junit.Assert.assertTrue;
5
6
import java.util.concurrent.TimeUnit;
7
8
import org.junit.After;
9
import org.junit.Before;
10
import org.junit.Test;
11
import org.openqa.selenium.By;
12
import org.openqa.selenium.NoAlertPresentException;
13
import org.openqa.selenium.firefox.FirefoxDriver;
14
15 120:ae1d99468601 hadi
public class AnotherTestWithSeleniumBuilder {
16 119:6973002711ef hadi
        FirefoxDriver wd;
17
18
        @Before
19
        public void setUp() throws Exception {
20
                wd = new FirefoxDriver();
21
                wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
22
        }
23
24
        @Test
25
        public void test() {
26
                wd.get("http://localhost:9100/m2u-upass-admin/common/Login.do");
27
                wd = (FirefoxDriver) wd.switchTo().frame(0);
28
                wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[2]/td[3]/input")).click();
29
                wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[2]/td[3]/input")).clear();
30
                wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[2]/td[3]/input")).sendKeys("administrator");
31
                wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[3]/td[3]/input")).click();
32
                wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[3]/td[3]/input")).clear();
33
                wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[3]/td[3]/input")).sendKeys("Mss@dm1n");
34
                wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[5]/td[5]/input")).click();
35
                wd.findElement(By.xpath("//div[2]/div[2]/div/div[1]/div/ul/li/ul/li[4]/a")).click();
36
                wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[2]/td[3]/input")).click();
37
                wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[2]/td[3]/input")).clear();
38
                wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[2]/td[3]/input")).sendKeys("test");
39
                wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/div[1]/input[1]")).click();
40
                wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/div[2]/form/input[2]")).click();
41
                if (!wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[3]/td[3]/select//option[2]"))
42
                                .isSelected()) {
43
                        wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[3]/td[3]/select//option[2]"))
44
                                        .click();
45
                }
46
                if (!wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[4]/td[3]/select//option[2]"))
47
                                .isSelected()) {
48
                        wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[4]/td[3]/select//option[2]"))
49
                                        .click();
50
                }
51
                wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/div[1]/input[1]")).click();
52
                assertTrue(wd.findElement(By.tagName("html")).getText().contains("m2u-test-user-1"));
53
                assertTrue(wd.findElement(By.tagName("html")).getText().contains("stock-user-1"));
54
                assertTrue(wd.findElement(By.tagName("html")).getText().contains("im2u-test-user-1"));
55
                wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/table[2]/tbody/tr[3]/td[1]/a")).click();
56
                assertTrue(wd.findElement(By.tagName("html")).getText().contains("Customer Enquiry - Details"));
57
                assertTrue(wd.findElement(By.tagName("html")).getText().contains("im2u-test-user-1"));
58
                assertTrue(wd.findElement(By.tagName("html")).getText().contains("Active"));
59
                wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/div/input[1]")).click();
60
                assertTrue((wd.findElements(By.cssSelector("tr.alt:nth-child(3)")).size() != 0));
61
                assertFalse((wd.findElements(By.cssSelector("tr.alt:nth-child(4)")).size() != 0));
62
        }
63
64
        @After
65
        public void tearDown() {
66
                wd.quit();
67
        }
68
69
        public static boolean isAlertPresent(FirefoxDriver wd) {
70
                try {
71
                        wd.switchTo().alert();
72
                        return true;
73
                } catch (NoAlertPresentException e) {
74
                        return false;
75
                }
76
        }
77
}