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.ITUtil;
20 import edu.samplu.common.WebDriverLegacyITBase;
21
22 import junit.framework.Assert;
23 import org.junit.Test;
24 import org.openqa.selenium.By;
25
26
27
28
29 public class ServerInfoLegacyIT extends WebDriverLegacyITBase {
30 @Override
31 public String getTestUrl() {
32 return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start";
33 }
34
35 @Test
36 public void testServerInfoIT() throws Exception {
37 waitAndClickByXpath("//button[contains(.,'Get Info Messages')]");
38 waitIsVisibleByXpath("//div[@data-messagesfor='Demo-ValidationLayout-SectionsPage']");
39
40 Assert.assertTrue(isVisibleByXpath("//div[@data-messagesfor='Demo-ValidationLayout-SectionsPage']"));
41 Assert.assertTrue(isElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-infoMessageItem"));
42 Assert.assertTrue(isVisible("div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]"));
43 Assert.assertTrue(isElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-infoMessageItem"));
44 Assert.assertTrue(isElementPresentByXpath("//div[@data-role='InputField']//img[@alt='Information']"));
45 fireMouseOverEventByXpath("//a[contains(.,'Field 1')]");
46 Assert.assertTrue(isElementPresent(".uif-infoHighlight"));
47 waitAndClickByXpath("//a[contains(.,'Field 1')]");
48 for (int second = 0;; second++) {
49 if (second >= 60) Assert.fail("timeout");
50 try { if (isVisible(".jquerybubblepopup-innerHtml")) break; } catch (Exception e) {}
51 Thread.sleep(1000);
52 }
53
54 Assert.assertTrue(isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems"));
55 Assert.assertTrue(isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field"));
56 waitAndTypeByName("field1", "");
57 fireEvent("field1", "blur");
58 fireEvent("field1", "focus");
59 for (int second = 0;; second++) {
60 if (second >= 60) Assert.fail("timeout");
61 try { if (isVisible(".jquerybubblepopup-innerHtml")) break; } catch (Exception e) {}
62 Thread.sleep(1000);
63 }
64
65 Assert.assertTrue(isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field"));
66 for (int second = 0;; second++) {
67 if (second >= 60) Assert.fail("timeout");
68 try { if (isVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems")) break; } catch (Exception e) {}
69 Thread.sleep(1000);
70 }
71
72 Assert.assertTrue(isVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field"));
73 waitAndTypeByName("field1", "b");
74 fireEvent("field1", "blur");
75 fireEvent("field1", "focus");
76 for (int second = 0;; second++) {
77 if (second >= 60) Assert.fail("timeout");
78 try { if (!isElementPresent(".jquerybubblepopup-innerHtml > .uif-clientMessageItems")) break; } catch (Exception e) {}
79 Thread.sleep(1000);
80 }
81 fireEvent("field1", "blur");
82 Thread.sleep(3000);
83 Assert.assertTrue(!isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field"));
84 Assert.assertFalse(isElementPresent(".jquerybubblepopup-innerHtml > .uif-clientMessageItems"));
85 fireEvent("field1", "focus");
86 clearTextByName("field1");
87 fireEvent("field1", "blur");
88 Assert.assertTrue(isElementPresent("div.uif-hasError"));
89 Assert.assertTrue(isElementPresent("img[src*=\"error.png\"]"));
90 }
91 }