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.travel.test; 017 018 import com.thoughtworks.selenium.DefaultSelenium; 019 import com.thoughtworks.selenium.Selenium; 020 import org.junit.After; 021 import org.junit.Before; 022 import org.junit.Test; 023 024 import static org.junit.Assert.assertEquals; 025 /** 026 * TODO Administrator don't forget to fill this in. 027 * 028 * @author Kuali Rice Team (rice.collab@kuali.org) 029 */ 030 public class FiscalOfficerInfoMaintenanceNewIT { 031 private Selenium selenium; 032 @Before 033 public void setUp() throws Exception { 034 //---- 3rd parameter(*firefox) can also be replaced by *chrome , *googlechrome. 035 selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url")); 036 selenium.start(); 037 } 038 039 @Test 040 public void testUntitled() throws Exception { 041 selenium.open("/portal.do?selectedTab=main"); 042 selenium.type("__login_user", "admin"); 043 selenium.click("//input[@value='Login']"); 044 selenium.waitForPageToLoad("50000"); 045 selenium.click("//a[@title='FiscalOfficerInfo Maintenance (New)']"); 046 selenium.waitForPageToLoad("50000"); 047 selenium.selectFrame("iframeportlet"); 048 String docId = selenium.getText("//span[contains(@id , '_attribute_span')][position()=1]"); 049 selenium.type("//input[@name='document.documentHeader.documentDescription']", "New FO Doc"); 050 selenium.type("//input[@name='document.newMaintainableObject.dataObject.id']", "5"); 051 selenium.type("//input[@name='document.newMaintainableObject.dataObject.userName']", "Jigar"); 052 053 // selenium.type("newCollectionLines['document.newMaintainableObject.dataObject.accounts'].number", "123123"); 054 // selenium.type("xpath = //input[@name='document.newMaintainableObject.dataObject.accounts[0].number']", "123123"); 055 // selenium.type("//input[contains(@name , '.number')]", "123123"); 056 // selenium.type("newCollectionLines['document.newMaintainableObject.dataObject.accounts'].name", "ChrisTravelAcc"); 057 // selenium.type("xpath = //input[@name='document.newMaintainableObject.dataObject.accounts[0].name']", "ChrisTravelAcc"); 058 // selenium.type("//input[contains(@name , '.name')]", "JustinTravelAcc"); 059 // selenium.click("add"); 060 // selenium.click("//input[@value='add']"); 061 // System.out.println("adding Row"); 062 // selenium.wait(90000); 063 064 selenium.click("//button[@value='save']"); 065 066 int docIdInt = Integer.valueOf(docId).intValue(); 067 068 selenium.waitForPageToLoad("50000"); 069 selenium.selectFrame("relative=up"); 070 selenium.click("//img[@alt='action list']"); 071 selenium.waitForPageToLoad("50000"); 072 selenium.selectFrame("iframeportlet"); 073 if(selenium.isElementPresent("link=Last")){ 074 selenium.click("link=Last"); 075 selenium.waitForPageToLoad("50000"); 076 selenium.click("link="+docIdInt); 077 } else { 078 selenium.click("link="+docIdInt); 079 } 080 081 Thread.sleep(5000); 082 String[] windowTitles = selenium.getAllWindowTitles(); 083 selenium.selectWindow(windowTitles[1]); 084 selenium.windowFocus(); 085 assertEquals(windowTitles[1], selenium.getTitle()); 086 087 //------submit-----// 088 selenium.selectFrame("relative=up"); 089 selenium.click("//button[@value='submit']"); 090 selenium.waitForPageToLoad("50000"); 091 selenium.close(); 092 //------submit over---// 093 094 //----step 2----// 095 selenium.selectWindow("null"); 096 selenium.windowFocus(); 097 selenium.click("//img[@alt='doc search']"); 098 selenium.waitForPageToLoad("50000"); 099 assertEquals(windowTitles[0], selenium.getTitle()); 100 selenium.selectFrame("iframeportlet"); 101 selenium.click("//input[@name='methodToCall.search' and @value='search']"); 102 selenium.waitForPageToLoad("50000"); 103 //----step 2 over ----// 104 105 //-----Step 3 verifies that doc is final-------// 106 assertEquals("FINAL", selenium.getText("//table[@id='row']/tbody/tr[1]/td[4]")); 107 selenium.selectFrame("relative=up"); 108 selenium.click("link=Main Menu"); 109 selenium.waitForPageToLoad("50000"); 110 assertEquals(windowTitles[0], selenium.getTitle()); 111 System.out.println("---------------------- :: Test complete :: ----------------------"); 112 //-----Step 3 verified that doc is final -------// 113 114 } 115 116 117 118 @After 119 public void tearDown() throws Exception { 120 selenium.stop(); 121 } 122 }