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