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