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   * tests that user 'admin', can initiate, save and submit a FiscalOfficerInfo maintenance document
27   * resulting in a final document
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class FiscalOfficerInfoMaintenanceNewIT {
32      private Selenium selenium;
33      @Before
34      public void setUp() throws Exception { 
35          //---- 3rd parameter(*firefox) can also be replaced by *chrome , *googlechrome.
36          selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url"));
37          selenium.start();
38      }
39      
40      @Test
41      public void testUntitled() throws Exception {
42          selenium.open(System.getProperty("remote.public.url"));
43          selenium.type("__login_user", "admin");
44          selenium.click("//input[@value='Login']");     
45          selenium.waitForPageToLoad("50000");
46          selenium.click("link=KRAD");
47          selenium.waitForPageToLoad("50000");
48          selenium.click("//a[@title='FiscalOfficerInfo Maintenance (New)']");
49          selenium.waitForPageToLoad("50000");
50          selenium.selectFrame("iframeportlet");
51          // String docId = selenium.getText("//span[contains(@id , '_attribute_span')][position()=1]");
52          String docId = selenium.getText("//div[@id='headerarea']/div/table/tbody/tr[1]/td[1]");
53          selenium.type("//input[@name='document.documentHeader.documentDescription']", "New FO Doc");      
54          selenium.type("//input[@name='document.newMaintainableObject.dataObject.id']", "5");      
55          selenium.type("//input[@name='document.newMaintainableObject.dataObject.userName']", "Jigar");
56          
57  //        selenium.type("newCollectionLines['document.newMaintainableObject.dataObject.accounts'].number", "123123");       
58  //        selenium.type("xpath = //input[@name='document.newMaintainableObject.dataObject.accounts[0].number']", "123123");
59  //        selenium.type("//input[contains(@name , '.number')]", "123123");
60  //        selenium.type("newCollectionLines['document.newMaintainableObject.dataObject.accounts'].name", "ChrisTravelAcc");
61  //        selenium.type("xpath = //input[@name='document.newMaintainableObject.dataObject.accounts[0].name']", "ChrisTravelAcc");
62  //        selenium.type("//input[contains(@name , '.name')]", "JustinTravelAcc");
63  //        selenium.click("add");
64  //        selenium.click("//input[@value='add']");
65  //        System.out.println("adding Row");
66  //        selenium.wait(90000);
67      
68          selenium.click("//button[@value='save']");
69          
70          int docIdInt = Integer.valueOf(docId).intValue(); 
71          
72          selenium.waitForPageToLoad("50000");
73          selenium.selectFrame("relative=up");
74          selenium.click("//img[@alt='action list']");     
75          selenium.waitForPageToLoad("50000");              
76          selenium.selectFrame("iframeportlet");
77          if(selenium.isElementPresent("link=Last")){
78              selenium.click("link=Last");
79              selenium.waitForPageToLoad("50000");
80              selenium.click("link="+docIdInt);
81          } else {                                  
82              selenium.click("link="+docIdInt);            
83          }
84          
85          Thread.sleep(5000); 
86          String[] windowTitles = selenium.getAllWindowTitles();              
87          selenium.selectWindow(windowTitles[1]);  
88          selenium.windowFocus();
89          assertEquals(windowTitles[1], selenium.getTitle());
90          
91          //------submit-----//
92          selenium.selectFrame("relative=up");
93          selenium.click("//button[@value='submit']");
94          selenium.waitForPageToLoad("50000");       
95          selenium.close();                   
96          //------submit over---//        
97          
98          //----step 2----//  
99          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 }