001 /*
002 * Copyright 2006-2012 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package edu.samplu.krad.validationmessagesview;
018
019 import edu.samplu.common.UpgradedSeleniumITBase;
020 import junit.framework.Assert;
021 import org.junit.Test;
022
023 /**
024 * @author Kuali Rice Team (rice.collab@kuali.org)
025 */
026 public class ServerErrorsIT extends UpgradedSeleniumITBase {
027
028 @Override
029 public String getTestUrl() {
030 return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start";
031 }
032
033 @Test
034 public void testServerErrorsIT() throws Exception {
035 selenium.click("//button[contains(.,'Get Error Messages')]");
036 selenium.waitForPageToLoad("30000");
037 // Assert.assertTrue(selenium.isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]")); // bugged isVisible? you can see it on the screen...
038 Assert.assertTrue(selenium.isElementPresent(
039 "css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-errorMessageItem"));
040 Assert.assertTrue(selenium.isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]"));
041 Assert.assertTrue(selenium.isElementPresent(
042 "css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-errorMessageItem"));
043 Assert.assertTrue(selenium.isElementPresent("css=div[data-role=\"InputField\"] img[alt=\"Error\"]"));
044 selenium.click("//a[contains(.,'\"Section 1 Title\"')]");
045 selenium.mouseOver("//a[contains(.,'Field 1')]");
046 Assert.assertTrue(selenium.isElementPresent("css=.uif-errorHighlight"));
047 selenium.click("//a[contains(.,'Field 1')]");
048 for (int second = 0; ; second++) {
049 if (second >= 60) {
050 Assert.fail("timeout");
051 }
052 try {
053 if (selenium.isVisible("css=.jquerybubblepopup-innerHtml")) {
054 break;
055 }
056 } catch (Exception e) {
057 }
058 Thread.sleep(1000);
059 }
060
061 Assert.assertTrue(selenium.isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems"));
062 Assert.assertTrue(selenium.isVisible(
063 "css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field"));
064 selenium.type("name=field1", "");
065 selenium.fireEvent("name=field1", "blur");
066 selenium.fireEvent("name=field1", "focus");
067 for (int second = 0; ; second++) {
068 if (second >= 60) {
069 Assert.fail("timeout");
070 }
071 try {
072 if (selenium.isVisible("css=.jquerybubblepopup-innerHtml")) {
073 break;
074 }
075 } catch (Exception e) {
076 }
077 Thread.sleep(1000);
078 }
079
080 Assert.assertTrue(selenium.isVisible(
081 "css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field"));
082 for (int second = 0; ; second++) {
083 if (second >= 60) {
084 Assert.fail("timeout");
085 }
086 try {
087 if (selenium.isVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")) {
088 break;
089 }
090 } catch (Exception e) {
091 }
092 Thread.sleep(1000);
093 }
094
095 Assert.assertTrue(selenium.isVisible(
096 "css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field"));
097 selenium.keyDown("name=field1", "t");
098 selenium.keyPress("name=field1", "t");
099 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 }