View Javadoc

1   
2   /*
3    * Copyright 2006-2012 The Kuali Foundation
4    *
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    * http://www.opensource.org/licenses/ecl2.php
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
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   * @author Kuali Rice Team (rice.collab@kuali.org)
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  //        Assert.assertTrue(isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]")); // bugged isVisible? you can see it on the screen...
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         // waitAndClickByXpath("//a[contains(.,'Section 1 Title')]");
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      //    keyDown(By.name("field1"), Keys('t'));
67      //    keyPress("name=field1", "t");
68      //    keyUp("field1", "t");
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  }