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 waitAndClick("//button[contains(.,'Get Error Messages')]"); 036 waitForPageToLoad(); 037 // Assert.assertTrue(isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]")); // bugged isVisible? you can see it on the screen... 038 Thread.sleep(1000); 039 assertElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-errorMessageItem"); 040 waitIsVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]"); 041 assertElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-errorMessageItem"); 042 assertElementPresent("css=div[data-role=\"InputField\"] img[alt=\"Error\"]"); 043 waitAndClick("//a[contains(.,'\"Section 1 Title\"')]"); 044 mouseOver("//a[contains(.,'Field 1')]"); 045 assertElementPresent("css=.uif-errorHighlight"); 046 waitAndClick("//a[contains(.,'Field 1')]"); 047 waitIsVisible("css=.jquerybubblepopup-innerHtml"); 048 049 waitIsVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems"); 050 waitIsVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field"); 051 waitAndType("name=field1", ""); 052 fireEvent("name=field1", "blur"); 053 fireEvent("name=field1", "focus"); 054 waitIsVisible("css=.jquerybubblepopup-innerHtml"); 055 056 waitIsVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field"); 057 waitIsVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems"); 058 waitIsVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field"); 059 keyDown("name=field1", "t"); 060 keyPress("name=field1", "t"); 061 keyUp("name=field1", "t"); 062 for (int second = 0; ; second++) { 063 if (second >= 60) { 064 Assert.fail("timeout"); 065 } 066 try { 067 if (!isElementPresent("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")) { 068 break; 069 } 070 } catch (Exception e) { 071 } 072 Thread.sleep(1000); 073 } 074 075 waitIsVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field"); 076 Assert.assertFalse(isElementPresent("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")); 077 } 078 }