001 /** 002 * Copyright 2005-2013 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 package edu.sampleu.krad.validationmessagesview; 017 018 import com.thoughtworks.selenium.SeleneseTestBase; 019 import org.junit.Test; 020 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase; 021 022 /** 023 * Tests the Component section in Rice. 024 * 025 * @author Kuali Rice Team (rice.collab@kuali.org) 026 */ 027 public class ServerSideTestViewAft extends WebDriverLegacyITBase { 028 029 /** 030 * "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&readOnlyFields=field91"; 031 */ 032 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=Demo-ValidationServerSide&methodToCall=start"; 033 034 @Override 035 protected String getBookmarkUrl() { 036 return BOOKMARK_URL; 037 } 038 039 protected void navigate() throws InterruptedException { 040 waitAndClickKRAD(); 041 waitAndClickByLinkText("ServerSide Constraint Validation Demo"); 042 switchToWindow("Kuali :: Validation Server-side Test View"); 043 } 044 045 //Code for KRAD Test Package. 046 protected void testServerSideTestView() throws Exception { 047 048 //MinMax length and value and Required Constraint 049 waitAndTypeByName("field9","a"); 050 waitAndTypeByName("field10","1"); 051 waitAndClickByXpath("//button[@id='usave']"); 052 Thread.sleep(4000); 053 assertTextPresent("MinMax Length test: Must be between 2 and 5 characters long"); 054 assertTextPresent("MinMax Value test: Value must be greater than 2 and no more than 50"); 055 assertTextPresent("Required constraint: 4 errors"); 056 057 //PreRequisite constraint 058 waitForElementPresentByXpath("//input[@name='field7' and @disabled]"); 059 waitAndClickByXpath("//input[@type='textbox' and @name='booleanField']"); 060 if(isElementPresentByXpath("//input[@name='field7' and @disabled]")) 061 { 062 fail("PreRequisite Constraint isn't working !"); 063 } 064 065 //MustOccurs constraint 066 waitAndTypeByName("field14","a"); 067 waitAndClickByXpath("//button[@id='usave']"); 068 Thread.sleep(4000); 069 070 } 071 072 @Test 073 public void testServerSideTestViewBookmark() throws Exception { 074 testServerSideTestView(); 075 passed(); 076 } 077 078 @Test 079 public void testServerSideTestViewNav() throws Exception { 080 testServerSideTestView(); 081 passed(); 082 } 083 }