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 public class FiscalOfficerInfoMaintenanceNewIT {
31 private Selenium selenium;
32 @Before
33 public void setUp() throws Exception {
34
35 selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url"));
36 selenium.start();
37 }
38
39 @Test
40 public void testUntitled() throws Exception {
41 selenium.open("/portal.do?selectedTab=main");
42 selenium.type("__login_user", "admin");
43 selenium.click("//input[@value='Login']");
44 selenium.waitForPageToLoad("50000");
45 selenium.click("//a[@title='FiscalOfficerInfo Maintenance (New)']");
46 selenium.waitForPageToLoad("50000");
47 selenium.selectFrame("iframeportlet");
48 String docId = selenium.getText("//span[contains(@id , '_attribute_span')][position()=1]");
49 selenium.type("//input[@name='document.documentHeader.documentDescription']", "New FO Doc");
50 selenium.type("//input[@name='document.newMaintainableObject.dataObject.id']", "5");
51 selenium.type("//input[@name='document.newMaintainableObject.dataObject.userName']", "Jigar");
52
53
54
55
56
57
58
59
60
61
62
63
64 selenium.click("//button[@value='save']");
65
66 int docIdInt = Integer.valueOf(docId).intValue();
67
68 selenium.waitForPageToLoad("50000");
69 selenium.selectFrame("relative=up");
70 selenium.click("//img[@alt='action list']");
71 selenium.waitForPageToLoad("50000");
72 selenium.selectFrame("iframeportlet");
73 if(selenium.isElementPresent("link=Last")){
74 selenium.click("link=Last");
75 selenium.waitForPageToLoad("50000");
76 selenium.click("link="+docIdInt);
77 } else {
78 selenium.click("link="+docIdInt);
79 }
80
81 Thread.sleep(5000);
82 String[] windowTitles = selenium.getAllWindowTitles();
83 selenium.selectWindow(windowTitles[1]);
84 selenium.windowFocus();
85 assertEquals(windowTitles[1], selenium.getTitle());
86
87
88 selenium.selectFrame("relative=up");
89 selenium.click("//button[@value='submit']");
90 selenium.waitForPageToLoad("50000");
91 selenium.close();
92
93
94
95 selenium.selectWindow("null");
96 selenium.windowFocus();
97 selenium.click("//img[@alt='doc search']");
98 selenium.waitForPageToLoad("50000");
99 assertEquals(windowTitles[0], selenium.getTitle());
100 selenium.selectFrame("iframeportlet");
101 selenium.click("//input[@name='methodToCall.search' and @value='search']");
102 selenium.waitForPageToLoad("50000");
103
104
105
106 assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]"));
107 selenium.selectFrame("relative=up");
108 selenium.click("link=Main Menu");
109 selenium.waitForPageToLoad("50000");
110 assertEquals(windowTitles[0], selenium.getTitle());
111 System.out.println("---------------------- :: Test complete :: ----------------------");
112
113
114 }
115
116
117
118 @After
119 public void tearDown() throws Exception {
120 selenium.stop();
121 }
122 }