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