1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.samplu.travel.krad.test;
18
19 import com.thoughtworks.selenium.*;
20 import org.junit.After;
21 import org.junit.Before;
22 import org.junit.Test;
23 import java.util.regex.Pattern;
24
25 import static junit.framework.Assert.assertTrue;
26 import static junit.framework.Assert.fail;
27
28
29
30
31
32 public class DirtyFieldsCheckIT {
33 private DefaultSelenium selenium;
34
35 @Before
36 public void setUp() throws Exception {
37 selenium = new DefaultSelenium("localhost", 4444, "*chrome", System.getProperty("remote.public.url"));
38 selenium.start();
39 }
40
41 @Test
42 public void testDirtyFieldsCheck() throws Exception {
43 selenium.open("/kr-dev/portal.do");
44 selenium.type("name=__login_user", "admin");
45 selenium.click("css=input[type=\"submit\"]");
46 selenium.waitForPageToLoad("30000");
47 selenium.click("link=KRAD");
48 selenium.waitForPageToLoad("30000");
49 selenium.click("link=Uif Components (Kitchen Sink)");
50 selenium.waitForPageToLoad("30000");
51 selenium.selectFrame("iframeportlet");
52 Thread.sleep(3000);
53 selenium.focus("id=u73_control");
54 selenium.type("id=u73_control", "test 1");
55 selenium.focus("id=u103_control");
56 selenium.type("id=u103_control", "test 2");
57
58 selenium.click("id=u967");
59 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
60 Thread.sleep(3000);
61 for (int second = 0;; second++) {
62 if (second >= 60) fail("timeout");
63 try { if (selenium.isElementPresent("id=u51_control")) break; } catch (Exception e) {}
64 Thread.sleep(1000);
65 }
66 selenium.focus("id=u51_control");
67 selenium.type("id=u51_control", "here");
68 selenium.focus("id=u81_control");
69 selenium.type("id=u81_control", "there");
70
71 selenium.click("id=u970");
72 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
73 Thread.sleep(3000);
74 for (int second = 0;; second++) {
75 if (second >= 60) fail("timeout");
76 try { if (selenium.isElementPresent("id=u114_control")) break; } catch (Exception e) {}
77 Thread.sleep(1000);
78 }
79 selenium.focus("id=u114_control");
80 selenium.type("id=u114_control", "this");
81 selenium.focus("id=u144_control");
82 selenium.type("id=u144_control", "that");
83
84 selenium.click("id=u973");
85 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
86 Thread.sleep(2000);
87 for (int second = 0;; second++) {
88 if (second >= 60) fail("timeout");
89 try { if (selenium.isElementPresent("id=u44_control")) break; } catch (Exception e) {}
90 Thread.sleep(1000);
91 }
92 selenium.focus("id=u44_control");
93 selenium.type("id=u44_control", "1");
94 selenium.focus("id=u74_control");
95 selenium.type("id=u74_control", "2");
96
97 selenium.click("id=u976");
98 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
99 }
100
101 @After
102 public void tearDown() throws Exception {
103 selenium.stop();
104 }
105 }