View Javadoc

1   /**
2    * Copyright 2005-2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package edu.samplu.travel.test;
17  
18  import com.thoughtworks.selenium.DefaultSelenium;
19  import com.thoughtworks.selenium.Selenium;
20  import org.junit.After;
21  import org.junit.Before;
22  import org.junit.Test;
23  
24  import static org.junit.Assert.assertEquals;
25  /**
26   * TODO Administrator don't forget to fill this in. 
27   * 
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   */
30  public class FiscalOfficerInfoMaintenanceNewIT {
31      private Selenium selenium;
32      @Before
33      public void setUp() throws Exception { 
34          //---- 3rd parameter(*firefox) can also be replaced by *chrome , *googlechrome.
35          selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url"));
36          selenium.start();
37      }
38      
39      @Test
40      public void testUntitled() throws Exception {
41          selenium.open("/portal.do?selectedTab=main");
42          selenium.type("__login_user", "admin");
43          selenium.click("//input[@value='Login']");     
44          selenium.waitForPageToLoad("50000");    
45          selenium.click("//a[@title='FiscalOfficerInfo Maintenance (New)']");
46          selenium.waitForPageToLoad("50000");
47          selenium.selectFrame("iframeportlet");       
48          String docId = selenium.getText("//span[contains(@id , '_attribute_span')][position()=1]");
49          selenium.type("//input[@name='document.documentHeader.documentDescription']", "New FO Doc");      
50          selenium.type("//input[@name='document.newMaintainableObject.dataObject.id']", "5");      
51          selenium.type("//input[@name='document.newMaintainableObject.dataObject.userName']", "Jigar");
52          
53  //        selenium.type("newCollectionLines['document.newMaintainableObject.dataObject.accounts'].number", "123123");       
54  //        selenium.type("xpath = //input[@name='document.newMaintainableObject.dataObject.accounts[0].number']", "123123");
55  //        selenium.type("//input[contains(@name , '.number')]", "123123");
56  //        selenium.type("newCollectionLines['document.newMaintainableObject.dataObject.accounts'].name", "ChrisTravelAcc");
57  //        selenium.type("xpath = //input[@name='document.newMaintainableObject.dataObject.accounts[0].name']", "ChrisTravelAcc");
58  //        selenium.type("//input[contains(@name , '.name')]", "JustinTravelAcc");
59  //        selenium.click("add");
60  //        selenium.click("//input[@value='add']");
61  //        System.out.println("adding Row");
62  //        selenium.wait(90000);
63      
64          selenium.click("//button[@value='save']");
65          
66          int docIdInt = Integer.valueOf(docId).intValue(); 
67          
68          selenium.waitForPageToLoad("50000");
69          selenium.selectFrame("relative=up");
70          selenium.click("//img[@alt='action list']");     
71          selenium.waitForPageToLoad("50000");              
72          selenium.selectFrame("iframeportlet");
73          if(selenium.isElementPresent("link=Last")){
74              selenium.click("link=Last");
75              selenium.waitForPageToLoad("50000");
76              selenium.click("link="+docIdInt);
77          } else {                                  
78              selenium.click("link="+docIdInt);            
79          }
80          
81          Thread.sleep(5000); 
82          String[] windowTitles = selenium.getAllWindowTitles();              
83          selenium.selectWindow(windowTitles[1]);  
84          selenium.windowFocus();
85          assertEquals(windowTitles[1], selenium.getTitle());
86          
87          //------submit-----//
88          selenium.selectFrame("relative=up");
89          selenium.click("//button[@value='submit']");
90          selenium.waitForPageToLoad("50000");       
91          selenium.close();                   
92          //------submit over---//        
93          
94          //----step 2----//  
95          selenium.selectWindow("null");
96          selenium.windowFocus();
97          selenium.click("//img[@alt='doc search']");
98          selenium.waitForPageToLoad("50000");
99          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 }