001 /** 002 * Copyright 2005-2011 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.admin.test; 017 018 import static org.junit.Assert.assertEquals; 019 import static org.junit.Assert.assertTrue; 020 021 import org.apache.commons.lang.RandomStringUtils; 022 import org.apache.commons.lang.StringUtils; 023 import org.junit.After; 024 import org.junit.Before; 025 import org.junit.Test; 026 027 import com.thoughtworks.selenium.DefaultSelenium; 028 import com.thoughtworks.selenium.Selenium; 029 030 /** 031 * tests that user 'admin', on blanket approving a new County maintenance document, results in a final document 032 * 033 * @author Kuali Rice Team (rice.collab@kuali.org) 034 */ 035 public class LocationCountyBlanketAppIT { 036 private Selenium selenium; 037 @Before 038 public void setUp() throws Exception { 039 selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url")); 040 selenium.start(); 041 } 042 043 @Test 044 public void testCounty() throws Exception { 045 String remotePublicUrl = System.getProperty("remote.public.url"); 046 // remove the trailing slash to allow for correction concatenation in locating the lookup buttons below 047 if (StringUtils.endsWith(remotePublicUrl, "/")) { 048 remotePublicUrl = StringUtils.removeEnd(remotePublicUrl, "/"); 049 } 050 selenium.open(remotePublicUrl); 051 assertEquals("Login", selenium.getTitle()); 052 selenium.type("__login_user", "admin"); 053 selenium.click("//input[@value='Login']"); 054 selenium.waitForPageToLoad("30000"); 055 assertEquals("Kuali Portal Index", selenium.getTitle()); 056 selenium.click("link=Administration"); 057 selenium.waitForPageToLoad("30000"); 058 assertEquals("Kuali Portal Index", selenium.getTitle()); 059 selenium.click("link=County"); 060 selenium.waitForPageToLoad("30000"); 061 assertEquals("Kuali Portal Index", selenium.getTitle()); 062 selenium.selectFrame("iframeportlet"); 063 selenium.click("//img[@alt='create new']"); 064 selenium.waitForPageToLoad("30000"); 065 //selenium.setSpeed("2000"); 066 String docId = selenium.getText("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]"); 067 assertTrue(selenium.isElementPresent("methodToCall.cancel")); 068 selenium.type("//input[@id='document.documentHeader.documentDescription']", "Validation Test County"); 069 selenium.click("methodToCall.performLookup.(!!org.kuali.rice.location.impl.country.CountryBo!!).(((code:document.newMaintainableObject.countryCode,))).((`document.newMaintainableObject.countryCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + remotePublicUrl 070 + "/kr/lookup.do;::::).anchor4"); 071 selenium.waitForPageToLoad("30000"); 072 selenium.type("code", "US"); 073 selenium.click("//input[@name='methodToCall.search' and @value='search']"); 074 selenium.waitForPageToLoad("30000"); 075 selenium.click("link=return value"); 076 selenium.waitForPageToLoad("30000"); 077 selenium.type("//input[@id='document.newMaintainableObject.code']", RandomStringUtils.randomAlphabetic(2).toUpperCase()); 078 selenium.click("methodToCall.performLookup.(!!org.kuali.rice.location.impl.state.StateBo!!).(((countryCode:document.newMaintainableObject.countryCode,code:document.newMaintainableObject.stateCode,))).((`document.newMaintainableObject.countryCode:countryCode,document.newMaintainableObject.stateCode:code,`)).((<>)).(([])).((**)).((^^)).((&&)).((//)).((~~)).(::::;" + remotePublicUrl 079 + "/kr/lookup.do;::::).anchor4"); 080 selenium.waitForPageToLoad("30000"); 081 selenium.type("code", "IN"); 082 selenium.click("//input[@name='methodToCall.search' and @value='search']"); 083 selenium.waitForPageToLoad("30000"); 084 selenium.click("link=return value"); 085 selenium.waitForPageToLoad("30000"); 086 selenium.type("//input[@id='document.newMaintainableObject.name']", "Validation Test County"); 087 selenium.click("//input[@id='document.newMaintainableObject.active']"); 088 selenium.click("methodToCall.blanketApprove"); 089 selenium.waitForPageToLoad("30000"); 090 selenium.selectWindow("null"); 091 selenium.click("//img[@alt='doc search']"); 092 selenium.waitForPageToLoad("30000"); 093 assertEquals("Kuali Portal Index", selenium.getTitle()); 094 selenium.selectFrame("iframeportlet"); 095 selenium.click("//input[@name='methodToCall.search' and @value='search']"); 096 selenium.waitForPageToLoad("30000"); 097 docId= "link=" + docId; 098 assertTrue(selenium.isElementPresent(docId)); 099 if(selenium.isElementPresent(docId)){ 100 assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]")); 101 }else{ 102 assertEquals(docId, selenium.getText("//table[@id='row']/tbody/tr[1]/td[1]")); 103 assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]")); 104 } 105 } 106 107 @After 108 public void tearDown() throws Exception { 109 selenium.stop(); 110 } 111 }