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.UpgradedSeleniumITBase;
20  import junit.framework.Assert;
21  import org.junit.Test;
22  
23  /**
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class ServerErrorsIT extends UpgradedSeleniumITBase {
27  
28      @Override
29      public String getTestUrl() {
30          return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start";
31      }
32  
33      @Test
34      public void testServerErrorsIT() throws Exception {
35          selenium.click("//button[contains(.,'Get Error Messages')]");
36          selenium.waitForPageToLoad("30000");
37  //        Assert.assertTrue(selenium.isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]")); // bugged isVisible? you can see it on the screen...
38          Assert.assertTrue(selenium.isElementPresent(
39                  "css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-errorMessageItem"));
40          Assert.assertTrue(selenium.isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]"));
41          Assert.assertTrue(selenium.isElementPresent(
42                  "css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-errorMessageItem"));
43          Assert.assertTrue(selenium.isElementPresent("css=div[data-role=\"InputField\"] img[alt=\"Error\"]"));
44          selenium.click("//a[contains(.,'\"Section 1 Title\"')]");
45          selenium.mouseOver("//a[contains(.,'Field 1')]");
46          Assert.assertTrue(selenium.isElementPresent("css=.uif-errorHighlight"));
47          selenium.click("//a[contains(.,'Field 1')]");
48          for (int second = 0; ; second++) {
49              if (second >= 60) {
50                  Assert.fail("timeout");
51              }
52              try {
53                  if (selenium.isVisible("css=.jquerybubblepopup-innerHtml")) {
54                      break;
55                  }
56              } catch (Exception e) {
57              }
58              Thread.sleep(1000);
59          }
60  
61          Assert.assertTrue(selenium.isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems"));
62          Assert.assertTrue(selenium.isVisible(
63                  "css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field"));
64          selenium.type("name=field1", "");
65          selenium.fireEvent("name=field1", "blur");
66          selenium.fireEvent("name=field1", "focus");
67          for (int second = 0; ; second++) {
68              if (second >= 60) {
69                  Assert.fail("timeout");
70              }
71              try {
72                  if (selenium.isVisible("css=.jquerybubblepopup-innerHtml")) {
73                      break;
74                  }
75              } catch (Exception e) {
76              }
77              Thread.sleep(1000);
78          }
79  
80          Assert.assertTrue(selenium.isVisible(
81                  "css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field"));
82          for (int second = 0; ; second++) {
83              if (second >= 60) {
84                  Assert.fail("timeout");
85              }
86              try {
87                  if (selenium.isVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")) {
88                      break;
89                  }
90              } catch (Exception e) {
91              }
92              Thread.sleep(1000);
93          }
94  
95          Assert.assertTrue(selenium.isVisible(
96                  "css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems  .uif-errorMessageItem-field"));
97          selenium.keyDown("name=field1", "t");
98          selenium.keyPress("name=field1", "t");
99          selenium.keyUp("name=field1", "t");
100         for (int second = 0; ; second++) {
101             if (second >= 60) {
102                 Assert.fail("timeout");
103             }
104             try {
105                 if (!selenium.isElementPresent("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")) {
106                     break;
107                 }
108             } catch (Exception e) {
109             }
110             Thread.sleep(1000);
111         }
112 
113         Assert.assertTrue(selenium.isVisible(
114                 "css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field"));
115         Assert.assertFalse(selenium.isElementPresent("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems"));
116     }
117 }