001/** 002 * Copyright 2005-2016 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.admin; 017 018import org.junit.Test; 019import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils; 020import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase; 021import org.kuali.rice.testtools.selenium.WebDriverUtils; 022import org.openqa.selenium.By; 023import org.openqa.selenium.support.ui.Select; 024 025/** 026 * test that repeated ajax refreshes work 027 * @author Kuali Rice Team (rice.collab@kuali.org) 028 */ 029public class AgendaEditRuleRefreshAft extends WebDriverLegacyITBase { 030 031 public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL+"?channelTitle=Agenda%20Lookup&channelUrl=" 032 + WebDriverUtils.getBaseUrlString() + AutomatedFunctionalTestUtils.KRAD_LOOKUP_METHOD 033 + "org.kuali.rice.krms.impl.repository.AgendaBo" 034 + AutomatedFunctionalTestUtils.SHOW_MAINTENANCE_LINKS 035 + "&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK; 036 037 @Override 038 protected String getBookmarkUrl() { 039 return BOOKMARK_URL; 040 } 041 042 @Override 043 protected void navigate() throws Exception { 044 waitAndClickByLinkText(AGENDA_LOOKUP_LINK_TEXT); 045 waitForPageToLoad(); 046 } 047 048 protected void testAgendaEditRuleRefresh() throws Exception { 049 selectFrameIframePortlet(); 050 waitAndClickSearchByText(); 051 // waitAndClickByXpath("//div[@class='uif-boxLayout uif-horizontalBoxLayout clearfix']/button[1]"); // jiraAwareWaitAndClick("id=32"); 052 waitAndClickByXpath("//a[@title='edit Agenda Definition with Agenda Id=T1000']", 053 "Does user have edit permissions?"); // jiraAwareWaitAndClick("id=194_line0"); 054 waitAndClickByXpath("//li/a[@class='agendaNode ruleNode']"); // jiraAwareWaitAndClick("//li[@id='473_node_0_parent_root']/a"); 055 waitAndClickByXpath("//li/a[@class='agendaNode logicNode whenTrueNode']"); 056 waitAndClickByLinkText("[-] collapse all"); 057 058 // click refresh several times 059 for (int i = 0; i < 6; i++) { 060 for (int second = 0;; second++) { 061 if (second >= waitSeconds) 062 jiraAwareFail(TIMEOUT_MESSAGE); 063 try { 064 if (isElementPresent(".kr-refresh-button")) 065 break; 066 } catch (Exception e) {} 067 Thread.sleep(1000); 068 } 069 waitAndClick("button.kr-refresh-button"); 070 } 071 } 072 073 protected void testAgendaEditRuleCompoundOperation() throws Exception { 074 selectFrameIframePortlet(); 075 waitAndClickSearchByText(); 076 waitAndClickByXpath("//a[@title='edit Agenda Definition with Agenda Id=T1001']", 077 "Does user have edit permissions?"); 078 waitAndClickByXpath("//li/a[@class='agendaNode ruleNode']"); 079 waitAndClickButtonByText("Edit Rule"); 080 waitForTextPresent("Campus Code = Muir AND Campus Code = Revelle AND Campus Code = Warren"); 081 082 waitAndSelectBy(By.xpath("//div[@id='RuleEditorView-Tree_tree']/ul/li/ul/li[2]/div/div/select"), "OR"); 083 waitForTextPresent("Campus Code = Muir OR Campus Code = Revelle OR Campus Code = Warren"); 084 Select select = new Select(driver.findElement(By.xpath( 085 "//div[@id='RuleEditorView-Tree_tree']/ul/li/ul/li[4]/div/div/select"))); 086 String selectedOption = select.getFirstSelectedOption().getText(); 087 assertEquals("The second drop down should also be OR", "OR", selectedOption); 088 089 waitAndSelectBy(By.xpath("//div[@id='RuleEditorView-Tree_tree']/ul/li/ul/li[4]/div/div/select"), "AND"); 090 waitForTextPresent("Campus Code = Muir AND Campus Code = Revelle AND Campus Code = Warren"); 091 Select select2 = new Select(driver.findElement(By.xpath( 092 "//div[@id='RuleEditorView-Tree_tree']/ul/li/ul/li[2]/div/div/select"))); 093 String selectedOption2 = select2.getFirstSelectedOption().getText(); 094 assertEquals("The first drop down should also be AND", "AND", selectedOption2); 095 } 096 097 /** 098 * test that repeated ajax refreshes work 099 */ 100 @Test 101 public void testAgendaEditRuleRefreshBookmark() throws Exception { 102 testAgendaEditRuleRefresh(); 103 passed(); 104 } 105 106 /** 107 * test that repeated ajax refreshes work 108 */ 109 @Test 110 public void testAgendaEditRuleRefreshNav() throws Exception { 111 testAgendaEditRuleRefresh(); 112 passed(); 113 } 114 115 /** 116 * test to verify that compound operations are set correctly when changed. 117 */ 118 @Test 119 public void testAgendaEditRuleCompoundOperationBookmark() throws Exception { 120 testAgendaEditRuleCompoundOperation(); 121 passed(); 122 } 123 124 /** 125 * test to verify that compound operations are set correctly when changed. 126 */ 127 @Test 128 public void testAgendaEditRuleCompoundOperationNav() throws Exception { 129 testAgendaEditRuleCompoundOperation(); 130 passed(); 131 } 132} 133