1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package edu.samplu.krad.validationmessagesview;
18
19 import edu.samplu.common.UpgradedSeleniumITBase;
20 import junit.framework.Assert;
21 import org.junit.Test;
22
23
24
25
26 public class ServerWarningsIT extends UpgradedSeleniumITBase {
27 @Override
28 public String getTestUrl() {
29 return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start";
30 }
31
32 @Test
33 public void testServerWarningsIT() throws Exception {
34 selenium.click("//button[contains(.,'Get Warning Messages')]");
35 selenium.waitForPageToLoad("30000");
36 Assert.assertTrue(selenium.isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]"));
37 Assert.assertTrue(selenium.isElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-warningMessageItem"));
38 Assert.assertTrue(selenium.isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]"));
39 Assert.assertTrue(selenium.isElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-warningMessageItem"));
40 Assert.assertTrue(selenium.isElementPresent("css=div[data-role=\"InputField\"] img[alt=\"Warning\"]"));
41 selenium.mouseOver("//a[contains(.,'Field 1')]");
42 Assert.assertTrue(selenium.isElementPresent("css=.uif-warningHighlight"));
43 selenium.click("//a[contains(.,'Field 1')]");
44 for (int second = 0;; second++) {
45 if (second >= 60) Assert.fail("timeout");
46 try { if (selenium.isVisible("css=.jquerybubblepopup-innerHtml")) break; } catch (Exception e) {}
47 Thread.sleep(1000);
48 }
49
50 Assert.assertTrue(selenium.isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems"));
51 Assert.assertTrue(selenium.isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field"));
52 selenium.type("name=field1", "");
53 selenium.fireEvent("name=field1", "blur");
54 selenium.fireEvent("name=field1", "focus");
55 for (int second = 0;; second++) {
56 if (second >= 60) Assert.fail("timeout");
57 try { if (selenium.isVisible("css=.jquerybubblepopup-innerHtml")) break; } catch (Exception e) {}
58 Thread.sleep(1000);
59 }
60
61 Assert.assertTrue(selenium.isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field"));
62 for (int second = 0;; second++) {
63 if (second >= 60) Assert.fail("timeout");
64 try { if (selenium.isVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")) break; } catch (Exception e) {}
65 Thread.sleep(1000);
66 }
67
68 Assert.assertTrue(selenium.isVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field"));
69 selenium.type("name=field1", "b");
70 selenium.keyDown("name=field1", "b");
71 selenium.keyUp("name=field1", "b");
72 selenium.typeKeys("name=field1", "\b\b\b");
73 for (int second = 0;; second++) {
74 if (second >= 60) Assert.fail("timeout");
75 try { if (!selenium.isElementPresent("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")) break; } catch (Exception e) {}
76 Thread.sleep(1000);
77 }
78
79 Assert.assertTrue(selenium.isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field"));
80 Assert.assertFalse(selenium.isElementPresent("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems"));
81 selenium.type("name=field1", "");
82 selenium.fireEvent("name=field1", "focus");
83 selenium.fireEvent("name=field1", "blur");
84 Assert.assertTrue(selenium.isElementPresent("css=.uif-hasError"));
85 Assert.assertTrue(selenium.isElementPresent("css=img[src*=\"error.png\"]"));
86 }
87 }