m2u-upass-admin / test / selenium / FirstTestWithSeleniumBuilder.java @ 145:759e0254d785
History | View | Annotate | Download (4.41 KB)
1 | 119:6973002711ef | hadi | package selenium; |
---|---|---|---|
2 | |||
3 | import static org.junit.Assert.assertTrue; |
||
4 | |||
5 | import java.util.concurrent.TimeUnit; |
||
6 | |||
7 | import org.junit.After; |
||
8 | import org.junit.Before; |
||
9 | import org.junit.Test; |
||
10 | import org.openqa.selenium.By; |
||
11 | import org.openqa.selenium.NoAlertPresentException; |
||
12 | import org.openqa.selenium.firefox.FirefoxDriver; |
||
13 | |||
14 | 120:ae1d99468601 | hadi | public class FirstTestWithSeleniumBuilder { |
15 | 119:6973002711ef | hadi | FirefoxDriver wd; |
16 | |||
17 | @Before
|
||
18 | public void setUp() throws Exception { |
||
19 | wd = new FirefoxDriver();
|
||
20 | wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS); |
||
21 | } |
||
22 | |||
23 | @Test
|
||
24 | public void test() { |
||
25 | wd.get("http://localhost:9100/m2u-upass-admin/common/Login.do");
|
||
26 | wd = (FirefoxDriver) wd.switchTo().frame(0);
|
||
27 | wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[2]/td[3]/input")).click();
|
||
28 | wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[2]/td[3]/input")).clear();
|
||
29 | wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[2]/td[3]/input")).sendKeys("administrator"); |
||
30 | wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[3]/td[3]/input")).click();
|
||
31 | wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[3]/td[3]/input")).clear();
|
||
32 | wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[3]/td[3]/input")).sendKeys("Mss@dm1n"); |
||
33 | wd.findElement(By.xpath("//div[2]/div[2]/form/table/tbody/tr[5]/td[5]/input")).click();
|
||
34 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[1]/div/ul/li/ul/li[1]/a")).click();
|
||
35 | assertTrue(wd.findElement(By.tagName("html")).getText().contains("No group(s) found")); |
||
36 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/div[2]/input")).click();
|
||
37 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[2]/td[3]/input")).click();
|
||
38 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[3]/td[3]/textarea")).click();
|
||
39 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[3]/td[3]/textarea")).clear();
|
||
40 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[3]/td[3]/textarea")).sendKeys(
|
||
41 | "Second Group Desc");
|
||
42 | if (!wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[6]/td[2]/ul/li/input")) |
||
43 | .isSelected()) { |
||
44 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[6]/td[2]/ul/li/input")).click();
|
||
45 | } |
||
46 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[2]/td[3]/input")).click();
|
||
47 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[2]/td[3]/input")).clear();
|
||
48 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[2]/td[3]/input")).sendKeys(
|
||
49 | "Second Group");
|
||
50 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[3]/td[3]/textarea")).click();
|
||
51 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table/tbody/tr[3]/td[3]/textarea"))
|
||
52 | .sendKeys("\\9");
|
||
53 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/div/input[2]")).click();
|
||
54 | assertTrue(wd.findElement(By.tagName("html")).getText().contains("Group Second Group will be created")); |
||
55 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/div/input[2]")).click();
|
||
56 | assertTrue(wd.findElement(By.tagName("html")).getText()
|
||
57 | .contains("Group Second Group has been successfully created"));
|
||
58 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[1]/div/ul/li/ul/li[1]/a")).click();
|
||
59 | assertTrue(wd.findElement(By.tagName("html")).getText().contains("Second Group")); |
||
60 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/table[2]/tbody/tr/td[1]/a")).click();
|
||
61 | assertTrue(wd.findElement(By.tagName("html")).getText().contains("Second Group Desc")); |
||
62 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/div/input[5]")).click();
|
||
63 | assertTrue(wd.findElement(By.tagName("html")).getText().contains("Group Second Group will be deleted.")); |
||
64 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[2]/div/form/div/input[2]")).click();
|
||
65 | assertTrue(wd.findElement(By.tagName("html")).getText()
|
||
66 | .contains("Group Second Group has been successfully deleted"));
|
||
67 | wd.findElement(By.xpath("//div[2]/div[2]/div/div[1]/div/ul/li/ul/li[1]/a")).click();
|
||
68 | assertTrue(wd.findElement(By.tagName("html")).getText().contains("No group(s) found")); |
||
69 | wd.findElement(By.xpath("//div[1]/table/tbody/tr/td[3]/a/img")).click();
|
||
70 | } |
||
71 | |||
72 | @After
|
||
73 | public void tearDown() { |
||
74 | wd.quit(); |
||
75 | } |
||
76 | |||
77 | public static boolean isAlertPresent(FirefoxDriver wd) { |
||
78 | try {
|
||
79 | wd.switchTo().alert(); |
||
80 | return true; |
||
81 | } catch (NoAlertPresentException e) {
|
||
82 | return false; |
||
83 | } |
||
84 | } |
||
85 | } |