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 edu.samplu.common.WebDriverLegacyITBase;
021 import junit.framework.Assert;
022 import org.junit.Test;
023
024 /**
025 * @author Kuali Rice Team (rice.collab@kuali.org)
026 */
027 public class ServerErrorsLegacyIT extends WebDriverLegacyITBase {
028
029 @Override
030 public String getTestUrl() {
031 return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start";
032 }
033
034 @Test
035 public void testServerErrorsIT() throws Exception {
036 waitAndClickByXpath("//button[contains(.,'Get Error Messages')]");
037 waitForPageToLoad();
038 // Assert.assertTrue(isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]")); // bugged isVisible? you can see it on the screen...
039 Thread.sleep(5000);
040 assertElementPresent("div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-errorMessageItem");
041 waitIsVisibleByXpath("//div[@data-headerfor='Demo-ValidationLayout-Section1']");
042 assertElementPresentByXpath("//*[@data-messageitemfor='Demo-ValidationLayout-Section1' and @class='uif-errorMessageItem']");
043 assertElementPresent("div[data-role=\"InputField\"] img[alt=\"Error\"]");
044 assertElementPresentByXpath("//a[contains(.,'Section 1 Title')]");
045 // waitAndClickByXpath("//a[contains(.,'Section 1 Title')]");
046 fireMouseOverEventByXpath("//a[contains(.,'Field 1')]");
047 assertElementPresent(".uif-errorMessageItem-field");
048 waitAndClickByXpath("//a[contains(.,'Field 1')]");
049 Thread.sleep(2000);
050 waitIsVisible(".jquerybubblepopup-innerHtml");
051
052 waitIsVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems");
053 waitIsVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field");
054 waitAndTypeByName("field1", "");
055 fireEvent("field1", "blur");
056 fireEvent("field1", "focus");
057 waitIsVisible(".jquerybubblepopup-innerHtml");
058
059 waitIsVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field");
060 waitIsVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems");
061 waitIsVisible(".jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field");
062 waitAndTypeByName("field1", "t");
063 // keyDown(By.name("field1"), Keys('t'));
064 // keyPress("name=field1", "t");
065 // keyUp("field1", "t");
066 for (int second = 0; ; second++) {
067 if (second >= 60) {
068 Assert.fail("timeout");
069 }
070 try {
071 if (!isElementPresent(".jquerybubblepopup-innerHtml > .uif-clientMessageItems")) {
072 break;
073 }
074 } catch (Exception e) {
075 }
076 Thread.sleep(1000);
077 }
078
079 waitIsVisible(".jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-errorMessageItem-field");
080 Assert.assertFalse(isElementPresent(".jquerybubblepopup-innerHtml > .uif-clientMessageItems"));
081 passed();
082 }
083 }