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 edu.samplu.krad.demo.uif.library;
17  
18  import com.thoughtworks.selenium.SeleneseTestBase;
19  import org.junit.Test;
20  import edu.samplu.common.SmokeTestBase;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class DemoLibraryWidgetsBreadcrumbsSmokeTest extends SmokeTestBase {
26  
27      /**
28       * /kr-krad/kradsampleapp?viewId=Demo-Breadcrumbs-View&methodToCall=start
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-Breadcrumbs-View&methodToCall=start";
31  
32      public static final String FIELD_TO_CHECK = "inputField9";
33      public static final String START_PAGE_TITLE = "Kuali";
34      public static final String TARGET_PAGE_TITLE = "Kuali :: View Title";
35      public static final String TARGET_URL_CHECK = "/kr-krad/kradsampleapp?viewId=Demo-Breadcrumbs-View";
36  
37      @Override
38      protected String getBookmarkUrl() {
39          return BOOKMARK_URL;
40      }
41  
42      @Override
43      protected void navigate() throws Exception {
44          waitAndClickById("Demo-LibraryLink", "");
45          waitAndClickByLinkText("Widgets");
46          waitAndClickByLinkText("Breadcrumbs");
47      }
48  
49      protected void testWidgetsBreadcrumbDefault() throws Exception {
50          waitAndClickByLinkText("Default Breadcrumbs");
51          switchToWindow(TARGET_PAGE_TITLE);
52          SeleneseTestBase.assertTrue(driver.getCurrentUrl().contains(TARGET_URL_CHECK + "1"));
53          assertElementPresentByName(FIELD_TO_CHECK);
54          driver.close();
55          switchToWindow(START_PAGE_TITLE);
56      }
57  
58      protected void testWidgetsBreadcrumbParentLocation() throws Exception {
59          waitAndClickByLinkText("ParentLocation");
60          waitAndClickByLinkText("Home ParentLocation");
61          switchToWindow(TARGET_PAGE_TITLE);
62          SeleneseTestBase.assertTrue(driver.getCurrentUrl().contains(TARGET_URL_CHECK + "2"));
63          assertElementPresentByName(FIELD_TO_CHECK);
64          driver.close();
65          switchToWindow(START_PAGE_TITLE);
66      }
67  
68      protected void testWidgetsBreadcrumbParentLocationChain() throws Exception {
69          waitAndClickByLinkText("ParentLocation Chain");
70          waitAndClickByLinkText("ParentLocation Chain/Trail");
71          switchToWindow(TARGET_PAGE_TITLE);
72          SeleneseTestBase.assertTrue(driver.getCurrentUrl().contains(TARGET_URL_CHECK + "3"));
73          assertElementPresentByName(FIELD_TO_CHECK);
74          driver.close();
75          switchToWindow(START_PAGE_TITLE);
76      }
77  
78      protected void testWidgetsBreadcrumbParentLocationPage() throws Exception {
79          waitAndClickByLinkText("ParentLocation Page");
80          waitAndClickByLinkText("ParentLocation View and Page");
81          switchToWindow(TARGET_PAGE_TITLE);
82          SeleneseTestBase.assertTrue(driver.getCurrentUrl().contains(TARGET_URL_CHECK + "4"));
83          assertElementPresentByName(FIELD_TO_CHECK);
84          driver.close();
85          switchToWindow(START_PAGE_TITLE);
86      }
87  
88      protected void testWidgetsBreadcrumbPreViewAndPrePage() throws Exception {
89          waitAndClickByLinkText("preView and prePage");
90          waitAndClickByLinkText("preView and prePage breadcrumbs");
91          switchToWindow(TARGET_PAGE_TITLE);
92          SeleneseTestBase.assertTrue(driver.getCurrentUrl().contains(TARGET_URL_CHECK + "5"));
93          assertElementPresentByName(FIELD_TO_CHECK);
94          driver.close();
95          switchToWindow(START_PAGE_TITLE);
96      }
97  
98      protected void testWidgetsBreadcrumbBreadcrumbLabel() throws Exception {
99          waitAndClickByLinkText("Breadcrumb Label");
100         waitAndClickByLinkText("Override Breadcrumb Label");
101         switchToWindow(TARGET_PAGE_TITLE);
102         SeleneseTestBase.assertTrue(driver.getCurrentUrl().contains(TARGET_URL_CHECK + "6"));
103         assertElementPresentByName(FIELD_TO_CHECK);
104         driver.close();
105         switchToWindow(START_PAGE_TITLE);
106     }
107 
108     protected void testWidgetsBreadcrumbHomewardPath() throws Exception {
109         waitAndClickByLinkText("Homeward Path");
110         waitAndClickByLinkText("Homeward Path Breadcrumbs");
111         switchToWindow(TARGET_PAGE_TITLE);
112         SeleneseTestBase.assertTrue(driver.getCurrentUrl().contains(TARGET_URL_CHECK + "7"));
113         assertElementPresentByName(FIELD_TO_CHECK);
114         driver.close();
115         switchToWindow(START_PAGE_TITLE);
116     }
117 
118     protected void testWidgetsBreadcrumbPathBased() throws Exception {
119         waitAndClickByLinkText("Path-based");
120         waitAndClickByLinkText("Path-based Breadcrumbs");
121         switchToWindow(TARGET_PAGE_TITLE);
122         SeleneseTestBase.assertTrue(driver.getCurrentUrl().contains(TARGET_URL_CHECK + "8"));
123         waitAndClickByLinkText("Page 2");
124         assertElementPresentByName("inputField9");
125         driver.close();
126         switchToWindow(START_PAGE_TITLE);
127     }
128 
129     protected void testWidgetsBreadcrumbOverrides() throws Exception {
130         waitAndClickByLinkText("Overrides");
131         waitAndClickByLinkText("Breadcrumb Overrides");
132         switchToWindow(TARGET_PAGE_TITLE);
133         SeleneseTestBase.assertTrue(driver.getCurrentUrl().contains(TARGET_URL_CHECK + "9"));
134         assertElementPresentByName(FIELD_TO_CHECK);
135         driver.close();
136         switchToWindow(START_PAGE_TITLE);
137     }
138 
139     protected void testWidgetsBreadcrumbSiblingBreadcrumbs() throws Exception {
140         waitAndClickByLinkText("Sibling Breadcrumbs");
141         waitAndClickById("u100164");
142         switchToWindow(TARGET_PAGE_TITLE);
143         SeleneseTestBase.assertTrue(driver.getCurrentUrl().contains(TARGET_URL_CHECK + "10"));
144         assertElementPresentByName(FIELD_TO_CHECK);
145         driver.close();
146         switchToWindow(START_PAGE_TITLE);
147     }
148 
149     @Test
150     public void testWidgetsBreadcrumbBookmark() throws Exception {
151         testWidgetsBreadcrumbDefault();
152         testWidgetsBreadcrumbParentLocation();
153         testWidgetsBreadcrumbParentLocationChain();
154         testWidgetsBreadcrumbParentLocationPage();
155         testWidgetsBreadcrumbPreViewAndPrePage();
156         testWidgetsBreadcrumbBreadcrumbLabel();
157         testWidgetsBreadcrumbHomewardPath();
158         testWidgetsBreadcrumbPathBased();
159         testWidgetsBreadcrumbOverrides();
160         testWidgetsBreadcrumbSiblingBreadcrumbs();
161         driver.close();
162         passed();
163     }
164 
165     @Test
166     public void testWidgetsBreadcrumbNav() throws Exception {
167         testWidgetsBreadcrumbDefault();
168         testWidgetsBreadcrumbParentLocation();
169         testWidgetsBreadcrumbParentLocationChain();
170         testWidgetsBreadcrumbParentLocationPage();
171         testWidgetsBreadcrumbPreViewAndPrePage();
172         testWidgetsBreadcrumbBreadcrumbLabel();
173         testWidgetsBreadcrumbHomewardPath();
174         testWidgetsBreadcrumbPathBased();
175         testWidgetsBreadcrumbOverrides();
176         testWidgetsBreadcrumbSiblingBreadcrumbs();
177         driver.close();
178         passed();
179     }
180 }