001/** 002 * Copyright 2005-2014 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 */ 016package edu.sampleu.main; 017 018import org.apache.commons.lang.RandomStringUtils; 019import org.junit.Test; 020import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils; 021import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase; 022import org.kuali.rice.testtools.selenium.WebDriverUtils; 023 024/** 025 * test that checks that rules can be added to agendas 026 * 027 * @author Kuali Rice Team (rice.collab@kuali.org) 028 */ 029public class AgendaEditorActiveInactiveCheckAft extends WebDriverLegacyITBase { 030 public static final String BOOKMARK_URL = 031 AutomatedFunctionalTestUtils.PORTAL 032 + "?channelTitle=Agenda%20Lookup&channelUrl=" 033 + WebDriverUtils.getBaseUrlString() 034 + AutomatedFunctionalTestUtils.KRAD_LOOKUP_METHOD 035 + "org.kuali.rice.krms.impl.repository.AgendaBo" 036 + AutomatedFunctionalTestUtils.SHOW_MAINTENANCE_LINKS 037 + "&returnLocation=" 038 + AutomatedFunctionalTestUtils.PORTAL_URL 039 + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK; 040 041 @Override 042 protected String getBookmarkUrl() { 043 return BOOKMARK_URL; 044 } 045 046 @Override 047 protected void navigate() throws Exception { 048 waitAndClickByLinkText(AGENDA_LOOKUP_LINK_TEXT); 049 waitForPageToLoad(); 050 } 051 052 protected void testAgendaEditorActiveInactiveCheck() throws Exception { 053 String uniqueText = RandomStringUtils.randomAlphabetic(9).toUpperCase(); 054 String uniqueRuleText = RandomStringUtils.randomAlphabetic(9).toUpperCase(); 055 056 //Add Inactive & Verify 057 selectFrameIframePortlet(); 058 waitAndClickByXpath("//a[contains(text(),'Create New')]"); 059 selectFrameIframePortlet(); 060 selectByName("document.newMaintainableObject.dataObject.namespace","Kuali Rules Test"); 061 waitAndTypeByName("document.newMaintainableObject.dataObject.agenda.name",uniqueText+"Inactive"); 062 waitAndTypeByName("document.newMaintainableObject.dataObject.contextName","Context1"); 063 waitAndClickByName("document.newMaintainableObject.dataObject.agenda.active"); 064 copyRuleFromExisting(uniqueText); 065 selectFrameIframePortlet(); 066 waitAndClickByXpath("//button[contains(text(),'Submit')]"); 067 waitAndClickConfirmSubmitOk(); 068 waitForTextPresent("Document was successfully submitted."); 069 selectParentWindow(); 070 waitAndClickMainMenu(); 071 selectFrameIframePortlet(); 072 navigate(); 073 selectFrameIframePortlet(); 074 waitAndTypeByName("lookupCriteria[name]",uniqueText+"Inactive"); 075 waitAndClickByXpath("//input[@name='lookupCriteria[active]' and @value='N']"); 076 waitAndClickButtonByExactText("Search"); 077 waitForTextPresent(uniqueText+"Inactive"); 078 079 // Add Active & Verify 080 waitAndClickByXpath("//a[contains(text(),'Create New')]"); 081 selectFrameIframePortlet(); 082 selectByName("document.newMaintainableObject.dataObject.namespace","Kuali Rules Test"); 083 waitAndTypeByName("document.newMaintainableObject.dataObject.agenda.name",uniqueText+"Active"); 084 waitAndTypeByName("document.newMaintainableObject.dataObject.contextName","Context1"); 085 copyRuleFromExisting(uniqueRuleText); 086 selectFrameIframePortlet(); 087 waitAndClickByXpath("//button[contains(text(),'Submit')]"); 088 waitAndClickConfirmSubmitOk(); 089 waitForTextPresent("Document was successfully submitted."); 090 selectParentWindow(); 091 waitAndClickMainMenu(); 092 selectFrameIframePortlet(); 093 navigate(); 094 selectFrameIframePortlet(); 095 waitAndTypeByName("lookupCriteria[name]",uniqueText+"Active"); 096 waitAndClickByXpath("//input[@name='lookupCriteria[active]' and @value='Y']"); 097 waitAndClickButtonByExactText("Search"); 098 waitForTextPresent(uniqueText+"Active"); 099 100 //Verify Both 101 waitAndClickButtonByExactText("Clear Values"); 102 waitAndTypeByName("lookupCriteria[name]",uniqueText+"Active"); 103 waitAndClickByXpath("//input[@name='lookupCriteria[active]' and @value='']"); 104 waitAndClickButtonByExactText("Search"); 105 waitForTextPresent(uniqueText+"Active"); 106 waitAndClickButtonByExactText("Clear Values"); 107 waitAndTypeByName("lookupCriteria[name]",uniqueText+"Inactive"); 108 waitAndClickByXpath("//input[@name='lookupCriteria[active]' and @value='']"); 109 waitAndClickButtonByExactText("Search"); 110 waitForTextPresent(uniqueText+"Inactive"); 111 } 112 113 protected void copyRuleFromExisting(String ruleName) throws Exception { 114 waitAndClickButtonByExactText("Add Rule"); 115 selectFrameIframePortlet(); 116 waitAndClickById("copyRuleName_quickfinder_act"); 117 gotoLightBox(); 118 waitAndClickButtonByText("Search"); 119 waitAndClickLinkContainingText("return value"); 120 selectFrameIframePortlet(); 121 waitAndClickButtonByExactText("Copy Rule"); 122 waitAndTypeByName("document.newMaintainableObject.dataObject.agendaItemLine.rule.name",ruleName); 123 if(!isElementPresentByXpath("//input[@name='document.newMaintainableObject.dataObject.agendaItemLine.rule.name' and @value='"+ruleName+"']")) { 124 waitAndTypeByName("document.newMaintainableObject.dataObject.agendaItemLine.rule.name",ruleName); 125 } 126 waitAndClickButtonByExactText("Add Rule"); 127 waitForElementPresentByXpath("//a[@class='ruleTreeNode simplePropositionNode']/p"); 128 } 129 130 /** 131 * test ActiveInactive Check 132 */ 133 @Test 134 public void testAgendaEditorActiveInactiveCheckBookmark() throws Exception { 135 testAgendaEditorActiveInactiveCheck(); 136 } 137 138 /** 139 * test ActiveInactive Check 140 */ 141 @Test 142 public void testAgendaEditorActiveInactiveCheckNav() throws Exception { 143 testAgendaEditorActiveInactiveCheck(); 144 } 145}