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