View Javadoc

1   /*
2    * Copyright 2005-2013 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 org.kuali.rice.krad.labs.kitchensink;
17  
18  import org.junit.Test;
19  import org.kuali.rice.testtools.selenium.WebDriverUtils;
20  
21  /**
22   * @author Kuali Rice Team (rice.collab@kuali.org)
23   */
24  
25  public class LabsEventExampleAft extends LabsKitchenSinkBase {
26  
27      public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&formKey=307ef15f-6e22-469b-bb4e-dc0d13056b5d&cacheKey=fkxfb8lxq8rozbctlgbz0k0zoa&pageId=UifCompView-Page11#UifCompView-Page11";
28      @Override
29      protected String getBookmarkUrl() {
30          return BOOKMARK_URL;
31      }
32  
33  	@Override
34  	protected void navigate() throws Exception {
35  		navigateToKitchenSink("Event Examples");
36  	}
37  	
38  	@Test
39      public void testKitchenSinkEventExamplesBookmark() throws Exception {
40          testKitchenSinkEventExamples();
41          passed();
42      }
43  
44      @Test
45      public void testKitchenSinkEventExamplesNav() throws Exception {
46          testKitchenSinkEventExamples();
47          passed();
48      }
49      
50      protected void testKitchenSinkEventExamples() throws InterruptedException 
51      {
52      	//OnClick examples on various components
53          waitAndClickByName("field100"); // Field Label
54      	alertAccept();
55          waitAndClickByName("field112"); // Date 1
56      	alertAccept();
57      	waitAndClickByXpath("//div[@data-parent='UifCompView-WindowEvents-Group1']/fieldset/span/input[@name='field118' and @value='blue']"); // Radio OnClick Example: blue
58      	waitForElementPresentByXpath("//div[@style='border: 1px solid rgb(153, 153, 153); width: auto; background-color: rgb(0, 0, 255);']");
59      	waitAndClickByXpath("//div[@data-parent='UifCompView-WindowEvents-Group1']/input[@type='checkbox' and @name='bField1']"); // Checkbox:
60      	alertAccept();
61      	waitAndClickByXpath("//input[@type='checkbox' and @name='field115' and @value='1']"); // Checkboxes 2: Option 1
62      	alertAccept();
63      	
64      	//Other Window Events: OnChange, onFocus, onBlur
65      	selectByXpath("//div[@data-parent='UifCompView-WindowEvents-Group2']/select","Lime");
66      	waitForElementPresentByXpath("//div[@style='background-color: rgb(0, 255, 0);']");
67      	fireEvent("field110", "focus");
68      	waitAndClickById("Group2-principalName_control");
69      	alertAccept();
70          waitAndClickByName("field131"); // Spinner Control
71      	alertAccept();
72      	
73      	//Click on image element
74      	assertElementPresentByXpath("//div[@id='Group4-Image1']");
75      	waitAndClickByXpath("//div[@id='Group4-Image1']/img");
76      	waitForElementPresentByXpath("//div[@style='margin-left: 80px;' and @id='Group4-Image1']");
77      	
78      	//Mouse over events
79      	fireMouseOverEventByXpath("//div[@style='border: 0px solid #999999; width:10%;']");
80      
81      	//Mouse Event on Button
82      	waitAndClickByXpath("//button[@style='margin-top:10px;']");
83      	alertAccept();
84      	
85      	//Other div elements
86      	fireMouseOverEventByXpath("//div[@style='background-color:red;height:200px; width:300px;']");
87      	waitForElementPresentByXpath("//div[@style='background-color: rgb(255, 255, 255); height: 200px; width: 300px;']");
88      	
89      	//OnKeyPress, KeyUp, KeyDown
90          waitAndTypeByXpath("(//input[@name='field100'])[3]", "a"); // Field Label:
91          alertAccept();
92      }
93  }