View Javadoc
1   /**
2    * Copyright 2005-2014 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.elements;
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 DemoElementsDropdownMenuAft extends WebDriverLegacyITBase {
26  
27      /**
28       * /kr-krad/kradsampleapp?viewId=Demo-DropdownMenuView
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-DropdownMenuView";
31   
32      @Override
33      protected String getBookmarkUrl() {
34          return BOOKMARK_URL;
35      }
36  
37      @Override
38      protected void navigate() throws Exception {
39          waitAndClickById("Demo-LibraryLink", "");
40          waitAndClickByLinkText("Elements");
41          waitAndClickByLinkText("Dropdown Menu");
42      }
43  
44      protected void testLibraryElementsDropdownBasic() throws Exception {
45          waitAndClickByLinkText("Basic Dropdown");
46          waitAndClickByLinkText("User thclark");
47          assertElementPresentByXpath("//a[contains(text(),'Preferences')]");
48          assertElementPresentByXpath("//a[contains(text(),'Logout')]");
49      }
50      
51      protected void testLibraryElementsDropdownWithDivider() throws Exception {
52          waitAndClickByLinkText("Dropdown with Divider");
53          waitAndClickByLinkText("Action List");
54          assertElementPresentByXpath("//a[contains(text(),'Proposal #1034')]");
55          assertElementPresentByXpath("//a[contains(text(),'Proposal #1035')]");
56          assertElementPresentByXpath("//a[contains(text(),'Proposal #1036')]");
57          assertElementPresentByXpath("//a[contains(text(),'Proposal #1037')]");
58          assertElementPresentByXpath("//a[contains(text(),'Full Action List')]");
59          assertElementPresentByXpath("//li[@class='divider']");
60      }
61      
62      protected void testLibraryElementsDropdownWithHeader() throws Exception {
63          waitAndClickByLinkText("Dropdown with Headers");
64          waitAndClickByLinkText("Favorites");
65          assertElementPresentByXpath("//a[contains(text(),'Proposal')]");
66          assertElementPresentByXpath("//a[contains(text(),'Budget')]");
67          assertElementPresentByXpath("//a[contains(text(),'Yearly Budget')]");
68          assertElementPresentByXpath("//li[@class='dropdown-header']");
69      }
70      
71      protected void testLibraryElementsDropdownWithDisabled() throws Exception {
72          waitAndClickByLinkText("Dropdown with Disabled");
73          waitAndClickByXpath("//a[contains(text(),'Select Action')]");
74          assertElementPresentByXpath("//a[contains(text(),'Approve') and @class='uif-actionLink']");
75          assertElementPresentByXpath("//a[contains(text(),'Disapprove') and @class='uif-actionLink disabled']");
76          assertElementPresentByXpath("//a[contains(text(),'Approve')]");
77      }
78      
79      protected void testLibraryElementsDropdownWithActionOptions() throws Exception {
80          waitAndClickByLinkText("Dropdown with Action Options");
81          waitAndClickByXpath("//a[contains(text(),'Select Action Options')]");
82          assertElementPresentByXpath("//a[contains(text(),'Refresh Section')]");
83          assertElementPresentByXpath("//a[contains(text(),'Action Script')]");
84          assertElementPresentByXpath("//a[contains(text(),'Pre-Submit Script')]");
85      }
86      
87      protected void testLibraryElementsDropdownWithToggleButton() throws Exception {
88          waitAndClickByLinkText("Dropdown with Toggle Button");
89          waitAndClickByXpath("//section[@id='Demo-DropdownMenu-Example6']/div/a/span[@class='caret']");
90          assertElementPresentByXpath("//a[contains(text(),'Preferences')]");
91          assertElementPresentByXpath("//a[contains(text(),'Logout')]");
92      }
93      
94      protected void testLibraryElementsDropdownWithTable() throws Exception {
95          waitAndClickByLinkText("Dropdown with Table");
96          waitAndClickByLinkText("more...");
97          assertTextPresent(new String[] {"Doc Nbr:","Initiator:","Status:","PI:","Created:","Updated:","Proposal Nbr:","Sponsor Name:"});
98          assertTextPresent(new String[] {"2743","thrclark","In Progress","Ken Graves","04:27pm 07/09/2013","12:22pm 07/12/2013","#23533","NIH"});
99      }
100 
101     private void testAllDropdowns() throws Exception {
102         testLibraryElementsDropdownBasic();
103         testLibraryElementsDropdownWithDivider();
104         testLibraryElementsDropdownWithHeader();
105         testLibraryElementsDropdownWithDisabled();
106         testLibraryElementsDropdownWithActionOptions();
107         testLibraryElementsDropdownWithToggleButton();
108         testLibraryElementsDropdownWithTable();
109     }
110 
111     @Test
112     public void testLibraryElementsDropdownBookmark() throws Exception {
113         testAllDropdowns();
114         passed();
115     }
116 
117     @Test
118     public void testLibraryElementsDropdownNav() throws Exception {
119         testAllDropdowns();
120         passed();
121     }  
122 }