View Javadoc
1   /**
2    * Copyright 2005-2015 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.demo.uif.library.controls;
17  
18  import org.junit.Test;
19  
20  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class LibraryControlSelectAft extends WebDriverLegacyITBase {
26  
27      /**
28       * /kr-krad/kradsampleapp?viewId=Demo-SelectControlView&methodToCall=start
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-SelectControlView&methodToCall=start";
31  
32      @Override
33      protected String getBookmarkUrl() {
34          return BOOKMARK_URL;
35      }
36  
37      @Override
38      protected void navigate() throws Exception {
39          waitAndClickLibraryLink();
40          waitAndClickByLinkText("Controls");
41          waitAndClickByLinkText("Select");
42      }
43  
44      protected void testLibraryControlSelectDefault() throws Exception {
45          assertElementPresentByXpath("//select[@name='inputField1']");
46          selectByName("inputField1","Option 1");
47      }
48      
49      protected void testLibraryControlSelectMultiSelect() throws Exception {
50          waitAndClickByLinkText("MultiSelect");
51          assertElementPresentByXpath("//select[@name='multiSelectField1' and @multiple='multiple']");
52          selectByName("multiSelectField1","Select 1");
53          selectByName("multiSelectField1","Select 2");
54          selectByName("multiSelectField1","Select 3");
55      }
56      
57      protected void testLibraryControlSelectDisabled() throws Exception {
58          waitAndClickByLinkText("Disabled");
59          assertElementPresentByXpath("//select[@name='inputField1' and @disabled='disabled']");
60      }
61      
62      protected void testLibraryControlSelectGroupedOptions() throws Exception {
63          waitAndClickByXpath("//li[@data-tabfor='Demo-SelectControl-Example5']/a");
64          waitForElementPresentByXpath("//select/optgroup[@label='American']");
65          waitForElementPresentByXpath("//select/optgroup/option");
66          waitForElementPresentByXpath("//select/optgroup[@label='Japan']");
67          waitForElementPresentByXpath("//select[@multiple]/optgroup[@label='American']");
68          waitForElementPresentByXpath("//select[@multiple]/optgroup/option");
69          waitForElementPresentByXpath("//select[@multiple]/optgroup[@label='Japan']");
70      }
71      
72      protected void testLibraryControlSelectNavigation() throws Exception {
73          waitAndClickByXpath("//li[@data-tabfor='Demo-SelectControl-Example4']/a");
74          assertElementPresentByXpath("//div[@data-parent='Demo-SelectControl-Example4']/select/option[@data-location='http://www.kuali.org']");
75          selectByXpath("//div[@data-parent='Demo-SelectControl-Example4']/select","Kuali.org");
76          //After this step it might throw some Javascript error on console as browser may invoke popup with "Stay on page" or "Leave Page" option.
77      }
78      
79      
80      @Test
81      public void testControlSelectBookmark() throws Exception {
82          testLibraryControlSelectDefault();
83          testLibraryControlSelectMultiSelect();
84          testLibraryControlSelectDisabled();
85          testLibraryControlSelectGroupedOptions();
86          testLibraryControlSelectNavigation();
87          passed();
88      }
89  
90      @Test
91      public void testControlSelectNav() throws Exception {
92          testLibraryControlSelectDefault();
93          testLibraryControlSelectMultiSelect();
94          testLibraryControlSelectDisabled();
95          testLibraryControlSelectGroupedOptions();
96          testLibraryControlSelectNavigation();
97          passed();
98      }  
99  }