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.WebDriverLegacyITBase; 020 import org.junit.Test; 021 import org.openqa.selenium.By; 022 023 import static com.thoughtworks.selenium.SeleneseTestBase.assertTrue; 024 025 /** 026 * @author Kuali Rice Team (rice.collab@kuali.org) 027 */ 028 public class ServerWarningsLegacyIT extends WebDriverLegacyITBase { 029 @Override 030 public String getTestUrl() { 031 return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start"; 032 } 033 034 @Test 035 public void testServerWarningsIT() throws Exception { 036 waitAndClickByXpath("//button[contains(.,'Get Warning Messages')]"); 037 waitForPageToLoad(); 038 Thread.sleep(3000); 039 assertTrue( "div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] not visible", 040 isVisible("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]")); 041 assertTrue("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-warningMessageItem not present", 042 isElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-warningMessageItem")); 043 assertTrue("div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] not visible", isVisible( 044 "div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]")); 045 assertTrue("div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-warningMessageItem not present", 046 isElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-warningMessageItem")); 047 assertTrue("div[data-role=\"InputField\"] img[alt=\"Warning\"] not present", isElementPresent( 048 "div[data-role=\"InputField\"] img[alt=\"Warning\"]")); 049 fireMouseOverEvent(By.xpath("//a[contains(.,'Field 1')]")); 050 assertTrue(".uif-warningHighlight no present when //a[contains(.,'Field 1')] is moused over", 051 isElementPresent(".uif-warningHighlight")); 052 waitAndClickByXpath("//a[contains(.,'Field 1')]"); 053 waitForElementVisible(".jquerybubblepopup-innerHtml", " after click on //a[contains(.,'Field 1')]"); 054 055 assertTrue(".jquerybubblepopup-innerHtml > .uif-serverMessageItems not visible", isVisible( 056 ".jquerybubblepopup-innerHtml > .uif-serverMessageItems")); 057 assertTrue(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible", 058 isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field")); 059 waitAndTypeByName("field1", ""); 060 fireEvent("field1","blur"); 061 fireMouseOverEventByName("field1"); 062 // fireEvent("field1","hover"); 063 waitForElementVisible(".jquerybubblepopup-innerHtml", " not visible after typing nothing in name=field1 then firing blur and focus events"); 064 065 assertTrue(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible after typing nothing in name=field1 then firing blur and focus events", 066 isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field")); 067 068 waitForElementVisible(".jquerybubblepopup-innerHtml> .uif-clientMessageItems", " not visible after typing nothing in name=field1 then firing blur and focus events"); 069 070 assertTrue(".jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field not visible after typing nothing in name=field1 then firing blur and focus events", 071 isVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field")); 072 073 waitAndTypeByName("field1", "b"); 074 fireEvent("field1","blur"); 075 fireMouseOverEventByName("field1"); 076 // fireEvent("field1","hover"); 077 waitForElementVisible(".jquerybubblepopup-innerHtml> .uif-serverMessageItems",""); 078 079 assertTrue(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible after typing b in name=field1 then firing blur and focus events", 080 isVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field")); 081 assertTrue(".jquerybubblepopup-innerHtml > .uif-clientMessageItems", !isElementPresent( 082 ".jquerybubblepopup-innerHtml > .uif-clientMessageItems")); 083 084 // waitAndTypeByName("field1", ""); 085 clearTextByName("field1"); 086 // fireEvent("field1", "focus"); 087 fireEvent("field1", "blur"); 088 fireMouseOverEventByName("field1"); 089 // fireEvent("field1","hover"); 090 assertTrue(".uif-hasError is not present after typing nothing in name=field1 and then firing focus and blur events", 091 isElementPresent(".uif-hasError")); 092 assertTrue( "img[src*=\"error.png\"] is not present after typing nothing in name=field1 and then firing focus and blur events", 093 isElementPresent("img[src*=\"error.png\"]")); 094 passed(); 095 } 096 097 private void typeBlurFocus(String name, String text) throws InterruptedException{ 098 waitAndTypeByName(name, text); 099 fireEvent(name, "blur"); 100 fireEvent(name, "focus"); 101 } 102 }