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 edu.samplu.common.UpgradedSeleniumITBase;
20 import org.junit.Test;
21
22 import static junit.framework.Assert.assertTrue;
23 import static junit.framework.Assert.fail;
24
25
26
27
28
29 public class DirtyFieldsCheckIT extends UpgradedSeleniumITBase {
30 @Override
31 public String getTestUrl() {
32 return PORTAL;
33 }
34
35 @Test
36 public void testDirtyFieldsCheck() throws Exception {
37 selenium.click("link=KRAD");
38 selenium.waitForPageToLoad("30000");
39 selenium.click("link=Uif Components (Kitchen Sink)");
40 selenium.waitForPageToLoad("30000");
41
42 Thread.sleep(3000);
43 selenium.focus("id=u73_control");
44 selenium.type("id=u73_control", "test 1");
45 selenium.focus("id=u103_control");
46 selenium.type("id=u103_control", "test 2");
47
48 selenium.click("id=u967");
49 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
50 Thread.sleep(3000);
51 for (int second = 0;; second++) {
52 if (second >= 60) fail("timeout");
53 try { if (selenium.isElementPresent("id=u51_control")) break; } catch (Exception e) {}
54 Thread.sleep(1000);
55 }
56 selenium.focus("id=u51_control");
57 selenium.type("id=u51_control", "here");
58 selenium.focus("id=u81_control");
59 selenium.type("id=u81_control", "there");
60
61 selenium.click("id=u970");
62 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
63 Thread.sleep(3000);
64 for (int second = 0;; second++) {
65 if (second >= 60) fail("timeout");
66 try { if (selenium.isElementPresent("id=u114_control")) break; } catch (Exception e) {}
67 Thread.sleep(1000);
68 }
69 selenium.focus("id=u114_control");
70 selenium.type("id=u114_control", "this");
71 selenium.focus("id=u144_control");
72 selenium.type("id=u144_control", "that");
73
74 selenium.click("id=u973");
75 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
76 Thread.sleep(2000);
77 for (int second = 0;; second++) {
78 if (second >= 60) fail("timeout");
79 try { if (selenium.isElementPresent("id=u44_control")) break; } catch (Exception e) {}
80 Thread.sleep(1000);
81 }
82 selenium.focus("id=u44_control");
83 selenium.type("id=u44_control", "1");
84 selenium.focus("id=u74_control");
85 selenium.type("id=u74_control", "2");
86
87 selenium.click("id=u976");
88 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$"));
89 }
90 }