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.samplu.krad.library.clientresponsiveness; 017 018 import org.junit.Test; 019 020 import org.kuali.rice.testtools.selenium.SmokeTestBase; 021 022 /** 023 * @author Kuali Rice Team (rice.collab@kuali.org) 024 */ 025 public class DemoLibraryClientResponsivenessDisableSmokeTest extends SmokeTestBase { 026 027 /** 028 * /kr-krad/kradsampleapp?viewId=Demo-Disable-View&methodToCall=start 029 */ 030 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-Disable-View&methodToCall=start"; 031 032 @Override 033 protected String getBookmarkUrl() { 034 return BOOKMARK_URL; 035 } 036 037 @Override 038 protected void navigate() throws Exception { 039 waitAndClickById("Demo-LibraryLink", ""); 040 waitAndClickByLinkText("Client Responsiveness"); 041 waitAndClickByLinkText("Disable"); 042 } 043 044 protected void testClientResponsivenessDisable() throws Exception { 045 //Scenario-1 - enabled 046 waitAndClickByXpath("//input[@type='radio' and @value='enable']"); 047 waitAndTypeByName("inputField2","a"); 048 waitAndTypeByName("inputField3","b"); 049 selectByName("inputField4", "Option 2"); 050 selectByName("multiSelectField1","Option 3"); 051 waitAndClickByXpath("//input[@type='radio' and @value='1']"); 052 waitAndClickByName("checkboxesField1"); 053 054 //Scenario-2 - disabled 055 waitAndClickByXpath("//input[@type='radio' and @value='disable']"); 056 if(isEnabledByName("inputField2") && isEnabledByName("inputField3") && isEnabledByName("inputField4") && isEnabledByName("inputField6") && 057 isEnabledByName("inputField7") && isEnabledByName("multiSelectField1")) { 058 fail("Field Not Disabled Properly."); 059 } 060 } 061 062 protected void testClientResponsivenessDisableOnChange() throws Exception { 063 selectByName("exampleShown","On change"); 064 065 //Scenario-1 066 assertElementPresentByXpath("//button[@class='btn btn-primary uif-primaryActionButton uif-boxLayoutHorizontalItem disabled']"); 067 waitAndTypeByName("inputField10","a"); 068 waitAndTypeByName("inputField11","a"); 069 waitAndTypeByName("inputField10", ""); 070 assertElementPresentByXpath("//button[@class='btn btn-primary uif-primaryActionButton uif-boxLayoutHorizontalItem disabled']"); 071 } 072 073 protected void testClientResponsivenessDisableOnKeyUp() throws Exception { 074 selectByName("exampleShown","On keyup"); 075 waitAndTypeByName("inputField13","disable"); 076 assertElementPresentByXpath("//button[contains(text(),'Action Button (keyUp)') and @class='btn btn-primary uif-primaryActionButton uif-boxLayoutHorizontalItem disabled']"); 077 waitAndClickByLinkText("Usage"); 078 assertElementPresentByXpath("//button[contains(text(),'Action Button (change)') and @class='btn btn-primary uif-primaryActionButton uif-boxLayoutHorizontalItem disabled']"); 079 } 080 081 protected void testClientResponsivenessDisableInCollections() throws Exception { 082 selectByName("exampleShown","In Collections"); 083 assertElementPresentByXpath("//input[@class='uif-textControl ignoreValid']"); 084 selectByName("newCollectionLines['collection1'].field1","Disable"); 085 Thread.sleep(1000); 086 assertElementPresentByXpath("//input[@disabled]"); 087 } 088 089 protected void testClientResponsivenessDisableColl() throws Exception { 090 selectByName("exampleShown","Coll. SpringEL Functions"); 091 waitAndClickByXpath("//input[@name='checkboxesField2' and @value='1']"); 092 assertElementPresentByXpath("//input[@name='inputField20' and @class='uif-textControl disabled']"); 093 waitAndClickByXpath("//input[@name='checkboxesField2' and @value='2']"); 094 waitAndClickByXpath("//input[@name='checkboxesField2' and @value='3']"); 095 assertElementPresentByXpath("//input[@name='inputField21' and @class='uif-textControl disabled']"); 096 } 097 098 @Test 099 public void testClientResponsivenessDisableBookmark() throws Exception { 100 testClientResponsivenessDisable(); 101 testClientResponsivenessDisableOnChange(); 102 testClientResponsivenessDisableOnKeyUp(); 103 testClientResponsivenessDisableInCollections(); 104 testClientResponsivenessDisableColl(); 105 passed(); 106 } 107 108 @Test 109 public void testClientResponsivenessDisableNav() throws Exception { 110 testClientResponsivenessDisable(); 111 testClientResponsivenessDisableOnChange(); 112 testClientResponsivenessDisableOnKeyUp(); 113 testClientResponsivenessDisableInCollections(); 114 testClientResponsivenessDisableColl(); 115 passed(); 116 } 117 }