1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.samplu.travel.test;
17
18 import com.thoughtworks.selenium.DefaultSelenium;
19 import com.thoughtworks.selenium.Selenium;
20 import org.junit.After;
21 import org.junit.Before;
22 import org.junit.Test;
23
24 import static org.junit.Assert.assertEquals;
25
26
27
28
29
30
31 public class FiscalOfficerInfoMaintenanceNewIT {
32 private Selenium selenium;
33 @Before
34 public void setUp() throws Exception {
35
36 selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url"));
37 selenium.start();
38 }
39
40 @Test
41 public void testUntitled() throws Exception {
42 selenium.open(System.getProperty("remote.public.url"));
43 selenium.type("__login_user", "admin");
44 selenium.click("//input[@value='Login']");
45 selenium.waitForPageToLoad("50000");
46 selenium.click("link=KRAD");
47 selenium.waitForPageToLoad("50000");
48 selenium.click("//a[@title='FiscalOfficerInfo Maintenance (New)']");
49 selenium.waitForPageToLoad("50000");
50 selenium.selectFrame("iframeportlet");
51
52 String docId = selenium.getText("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
53 selenium.type("//input[@name='document.documentHeader.documentDescription']", "New FO Doc");
54 selenium.type("//input[@name='document.newMaintainableObject.dataObject.id']", "5");
55 selenium.type("//input[@name='document.newMaintainableObject.dataObject.userName']", "Jigar");
56
57
58
59
60
61
62
63
64
65
66
67
68 selenium.click("//button[@value='save']");
69
70 int docIdInt = Integer.valueOf(docId).intValue();
71
72 selenium.waitForPageToLoad("50000");
73 selenium.selectFrame("relative=up");
74 selenium.click("//img[@alt='action list']");
75 selenium.waitForPageToLoad("50000");
76 selenium.selectFrame("iframeportlet");
77 if(selenium.isElementPresent("link=Last")){
78 selenium.click("link=Last");
79 selenium.waitForPageToLoad("50000");
80 selenium.click("link="+docIdInt);
81 } else {
82 selenium.click("link="+docIdInt);
83 }
84
85 Thread.sleep(5000);
86 String[] windowTitles = selenium.getAllWindowTitles();
87 selenium.selectWindow(windowTitles[1]);
88 selenium.windowFocus();
89 assertEquals(windowTitles[1], selenium.getTitle());
90
91
92 selenium.selectFrame("relative=up");
93 selenium.click("//button[@value='submit']");
94 selenium.waitForPageToLoad("50000");
95 selenium.close();
96
97
98
99 selenium.selectWindow("null");
100 selenium.windowFocus();
101 selenium.click("//img[@alt='doc search']");
102 selenium.waitForPageToLoad("50000");
103 assertEquals(windowTitles[0], selenium.getTitle());
104 selenium.selectFrame("iframeportlet");
105 selenium.click("//input[@name='methodToCall.search' and @value='search']");
106 selenium.waitForPageToLoad("50000");
107
108
109
110 assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]"));
111 selenium.selectFrame("relative=up");
112 selenium.click("link=Main Menu");
113 selenium.waitForPageToLoad("50000");
114 assertEquals(windowTitles[0], selenium.getTitle());
115 System.out.println("---------------------- :: Test complete :: ----------------------");
116
117
118 }
119
120 @After
121 public void tearDown() throws Exception {
122 selenium.stop();
123 }
124 }