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.ITUtil; 020 import edu.samplu.common.WebDriverLegacyITBase; 021 022 import junit.framework.Assert; 023 import org.junit.Test; 024 import org.openqa.selenium.By; 025 026 /** 027 * @author Kuali Rice Team (rice.collab@kuali.org) 028 */ 029 public class ServerInfoLegacyIT extends WebDriverLegacyITBase { 030 @Override 031 public String getTestUrl() { 032 return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start"; 033 } 034 035 @Test 036 public void testServerInfoIT() throws Exception { 037 waitAndClickByXpath("//button[contains(.,'Get Info Messages')]"); 038 waitIsVisibleByXpath("//div[@data-messagesfor='Demo-ValidationLayout-SectionsPage']"); 039 //Thread.sleep(3000); 040 Assert.assertTrue(isVisibleByXpath("//div[@data-messagesfor='Demo-ValidationLayout-SectionsPage']")); 041 Assert.assertTrue(isElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-infoMessageItem")); 042 Assert.assertTrue(isVisible("div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]")); 043 Assert.assertTrue(isElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-infoMessageItem")); 044 Assert.assertTrue(isElementPresentByXpath("//div[@data-role='InputField']//img[@alt='Information']")); 045 fireMouseOverEventByXpath("//a[contains(.,'Field 1')]"); 046 Assert.assertTrue(isElementPresent(".uif-infoHighlight")); 047 waitAndClickByXpath("//a[contains(.,'Field 1')]"); 048 for (int second = 0;; second++) { 049 if (second >= 60) Assert.fail("timeout"); 050 try { if (isVisible(".jquerybubblepopup-innerHtml")) break; } catch (Exception e) {} 051 Thread.sleep(1000); 052 } 053 054 Assert.assertTrue(isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems")); 055 Assert.assertTrue(isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field")); 056 waitAndTypeByName("field1", ""); 057 fireEvent("field1", "blur"); 058 fireEvent("field1", "focus"); 059 for (int second = 0;; second++) { 060 if (second >= 60) Assert.fail("timeout"); 061 try { if (isVisible(".jquerybubblepopup-innerHtml")) break; } catch (Exception e) {} 062 Thread.sleep(1000); 063 } 064 065 Assert.assertTrue(isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field")); 066 for (int second = 0;; second++) { 067 if (second >= 60) Assert.fail("timeout"); 068 try { if (isVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems")) break; } catch (Exception e) {} 069 Thread.sleep(1000); 070 } 071 072 Assert.assertTrue(isVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field")); 073 waitAndTypeByName("field1", "b"); 074 fireEvent("field1", "blur"); 075 fireEvent("field1", "focus"); 076 for (int second = 0;; second++) { 077 if (second >= 60) Assert.fail("timeout"); 078 try { if (!isElementPresent(".jquerybubblepopup-innerHtml > .uif-clientMessageItems")) break; } catch (Exception e) {} 079 Thread.sleep(1000); 080 } 081 fireEvent("field1", "blur"); 082 Thread.sleep(3000); 083 Assert.assertTrue(!isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field")); 084 Assert.assertFalse(isElementPresent(".jquerybubblepopup-innerHtml > .uif-clientMessageItems")); 085 fireEvent("field1", "focus"); 086 clearTextByName("field1"); 087 fireEvent("field1", "blur"); 088 Assert.assertTrue(isElementPresent("div.uif-hasError")); 089 Assert.assertTrue(isElementPresent("img[src*=\"error.png\"]")); 090 } 091 }