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.travel.krad.test; 018 019 import edu.samplu.common.UpgradedSeleniumITBase; 020 import org.junit.Test; 021 022 import static junit.framework.Assert.assertTrue; 023 import static junit.framework.Assert.fail; 024 /** 025 * test that dirty fields check happens for all pages in a view 026 * 027 * @author Kuali Rice Team (rice.collab@kuali.org) 028 */ 029 public class DirtyFieldsCheckIT extends UpgradedSeleniumITBase { 030 @Override 031 public String getTestUrl() { 032 return PORTAL; 033 } 034 035 @Test 036 public void testDirtyFieldsCheck() throws Exception { 037 selenium.click("link=KRAD"); 038 selenium.waitForPageToLoad("30000"); 039 selenium.click("link=Uif Components (Kitchen Sink)"); 040 selenium.waitForPageToLoad("30000"); 041 // selenium.selectFrame("iframeportlet"); 042 Thread.sleep(3000); 043 selenium.focus("id=u73_control"); 044 selenium.type("id=u73_control", "test 1"); 045 selenium.focus("id=u103_control"); 046 selenium.type("id=u103_control", "test 2"); 047 // 'Other Fields' navigation link 048 selenium.click("id=u967"); 049 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$")); 050 Thread.sleep(3000); 051 for (int second = 0;; second++) { 052 if (second >= 60) fail("timeout"); 053 try { if (selenium.isElementPresent("id=u51_control")) break; } catch (Exception e) {} 054 Thread.sleep(1000); 055 } 056 selenium.focus("id=u51_control"); 057 selenium.type("id=u51_control", "here"); 058 selenium.focus("id=u81_control"); 059 selenium.type("id=u81_control", "there"); 060 // 'Validation' navigation link 061 selenium.click("id=u970"); 062 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$")); 063 Thread.sleep(3000); 064 for (int second = 0;; second++) { 065 if (second >= 60) fail("timeout"); 066 try { if (selenium.isElementPresent("id=u114_control")) break; } catch (Exception e) {} 067 Thread.sleep(1000); 068 } 069 selenium.focus("id=u114_control"); 070 selenium.type("id=u114_control", "this"); 071 selenium.focus("id=u144_control"); 072 selenium.type("id=u144_control", "that"); 073 // 'Validation - Regex' navigation link 074 selenium.click("id=u973"); 075 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$")); 076 Thread.sleep(2000); 077 for (int second = 0;; second++) { 078 if (second >= 60) fail("timeout"); 079 try { if (selenium.isElementPresent("id=u44_control")) break; } catch (Exception e) {} 080 Thread.sleep(1000); 081 } 082 selenium.focus("id=u44_control"); 083 selenium.type("id=u44_control", "1"); 084 selenium.focus("id=u74_control"); 085 selenium.type("id=u74_control", "2"); 086 // 'Progressive Disclosure' navigation link 087 selenium.click("id=u976"); 088 assertTrue(selenium.getConfirmation().matches("^Form has unsaved data\\. Do you want to leave anyway[\\s\\S]$")); 089 } 090 }