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 edu.samplu.common.WebDriverLegacyITBase;
21  import junit.framework.Assert;
22  import org.junit.Test;
23  
24  /**
25   * @author Kuali Rice Team (rice.collab@kuali.org)
26   */
27  public class ServerErrorsLegacyIT extends WebDriverLegacyITBase {
28  
29      @Override
30      public String getTestUrl() {
31          return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start";
32      }
33  
34      @Test
35      public void testServerErrorsIT() throws Exception {
36          waitAndClickByXpath("//button[contains(.,'Get Error Messages')]");
37          waitForPageToLoad();
38  //        Assert.assertTrue(isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]")); // bugged isVisible? you can see it on the screen...
39          Thread.sleep(5000);
40          assertElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-errorMessageItem");
41          waitIsVisibleByXpath("//div[@data-headerfor='Demo-ValidationLayout-Section1']");
42          assertElementPresentByXpath("//*[@data-messageitemfor='Demo-ValidationLayout-Section1' and @class='uif-errorMessageItem']");
43          assertElementPresent("div[data-role=\"InputField\"] img[alt=\"Error\"]");
44          assertElementPresentByXpath("//a[contains(.,'Section 1 Title')]");
45         // waitAndClickByXpath("//a[contains(.,'Section 1 Title')]");
46          fireMouseOverEventByXpath("//a[contains(.,'Field 1')]");
47          assertElementPresent(".uif-errorMessageItem-field");
48          waitAndClickByXpath("//a[contains(.,'Field 1')]");
49          Thread.sleep(2000);
50          waitIsVisible(".jquerybubblepopup-innerHtml");
51  
52          waitIsVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems");
53          waitIsVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field");
54          waitAndTypeByName("field1", "");
55          fireEvent("field1", "blur");
56          fireEvent("field1", "focus");
57          waitIsVisible(".jquerybubblepopup-innerHtml");
58  
59          waitIsVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field");
60          waitIsVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems");
61          waitIsVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems  .uif-errorMessageItem-field");
62          waitAndTypeByName("field1", "t");
63      //    keyDown(By.name("field1"), Keys('t'));
64      //    keyPress("name=field1", "t");
65      //    keyUp("field1", "t");
66          for (int second = 0; ; second++) {
67              if (second >= 60) {
68                  Assert.fail("timeout");
69              }
70              try {
71                  if (!isElementPresent(".jquerybubblepopup-innerHtml > .uif-clientMessageItems")) {
72                      break;
73                  }
74              } catch (Exception e) {
75              }
76              Thread.sleep(1000);
77          }
78  
79          waitIsVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field");
80          Assert.assertFalse(isElementPresent(".jquerybubblepopup-innerHtml > .uif-clientMessageItems"));
81          passed();
82      }
83  }