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.WebDriverLegacyITBase;
20 import org.junit.Test;
21 import org.openqa.selenium.By;
22
23 import static com.thoughtworks.selenium.SeleneseTestBase.assertTrue;
24
25
26
27
28 public class ServerWarningsLegacyIT extends WebDriverLegacyITBase {
29 @Override
30 public String getTestUrl() {
31 return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start";
32 }
33
34 @Test
35 public void testServerWarningsIT() throws Exception {
36 waitAndClickByXpath("//button[contains(.,'Get Warning Messages')]");
37 waitForPageToLoad();
38 Thread.sleep(3000);
39 assertTrue( "div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] not visible",
40 isVisible("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]"));
41 assertTrue("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-warningMessageItem not present",
42 isElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-warningMessageItem"));
43 assertTrue("div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] not visible", isVisible(
44 "div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]"));
45 assertTrue("div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-warningMessageItem not present",
46 isElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-warningMessageItem"));
47 assertTrue("div[data-role=\"InputField\"] img[alt=\"Warning\"] not present", isElementPresent(
48 "div[data-role=\"InputField\"] img[alt=\"Warning\"]"));
49 fireMouseOverEvent(By.xpath("//a[contains(.,'Field 1')]"));
50 assertTrue(".uif-warningHighlight no present when //a[contains(.,'Field 1')] is moused over",
51 isElementPresent(".uif-warningHighlight"));
52 waitAndClickByXpath("//a[contains(.,'Field 1')]");
53 waitForElementVisible(".jquerybubblepopup-innerHtml", " after click on //a[contains(.,'Field 1')]");
54
55 assertTrue(".jquerybubblepopup-innerHtml > .uif-serverMessageItems not visible", isVisible(
56 ".jquerybubblepopup-innerHtml > .uif-serverMessageItems"));
57 assertTrue(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible",
58 isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field"));
59 waitAndTypeByName("field1", "");
60 fireEvent("field1","blur");
61 fireMouseOverEventByName("field1");
62
63 waitForElementVisible(".jquerybubblepopup-innerHtml", " not visible after typing nothing in name=field1 then firing blur and focus events");
64
65 assertTrue(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible after typing nothing in name=field1 then firing blur and focus events",
66 isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field"));
67
68 waitForElementVisible(".jquerybubblepopup-innerHtml> .uif-clientMessageItems", " not visible after typing nothing in name=field1 then firing blur and focus events");
69
70 assertTrue(".jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field not visible after typing nothing in name=field1 then firing blur and focus events",
71 isVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field"));
72
73 waitAndTypeByName("field1", "b");
74 fireEvent("field1","blur");
75 fireMouseOverEventByName("field1");
76
77 waitForElementVisible(".jquerybubblepopup-innerHtml> .uif-serverMessageItems","");
78
79 assertTrue(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible after typing b in name=field1 then firing blur and focus events",
80 isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field"));
81 assertTrue(".jquerybubblepopup-innerHtml > .uif-clientMessageItems", !isElementPresent(
82 ".jquerybubblepopup-innerHtml > .uif-clientMessageItems"));
83
84
85 clearTextByName("field1");
86
87 fireEvent("field1", "blur");
88 fireMouseOverEventByName("field1");
89
90 assertTrue(".uif-hasError is not present after typing nothing in name=field1 and then firing focus and blur events",
91 isElementPresent(".uif-hasError"));
92 assertTrue( "img[src*=\"error.png\"] is not present after typing nothing in name=field1 and then firing focus and blur events",
93 isElementPresent("img[src*=\"error.png\"]"));
94 passed();
95 }
96
97 private void typeBlurFocus(String name, String text) throws InterruptedException{
98 waitAndTypeByName(name, text);
99 fireEvent(name, "blur");
100 fireEvent(name, "focus");
101 }
102 }