View Javadoc

1    /*
2    * Copyright 2006-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * @author Kuali Rice Team (rice.collab@kuali.org)
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       //   fireEvent("field1","hover");
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        //  fireEvent("field1","hover");
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  //        waitAndTypeByName("field1", "");
85          clearTextByName("field1");
86     //     fireEvent("field1", "focus");
87          fireEvent("field1", "blur");
88          fireMouseOverEventByName("field1");
89  //        fireEvent("field1","hover");
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 }