001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package edu.samplu.krad.demo.uif.library;
017
018 import com.thoughtworks.selenium.SeleneseTestBase;
019 import org.junit.Test;
020
021 /**
022 * @author Kuali Rice Team (rice.collab@kuali.org)
023 */
024 public class DemoLibraryWidgetsBreadcrumbsSmokeTest extends DemoLibraryBase {
025
026 /**
027 * /kr-krad/kradsampleapp?viewId=Demo-Breadcrumbs-View&methodToCall=start
028 */
029 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-Breadcrumbs-View&methodToCall=start";
030
031 /**
032 * inputField9
033 */
034 public static final String FIELD_TO_CHECK = "inputField9";
035
036 /**
037 * Kuali
038 */
039 public static final String START_PAGE_TITLE = "Kuali";
040
041 /**
042 * Kuali :: View Title
043 */
044 public static final String TARGET_PAGE_TITLE = "Kuali :: View Title";
045
046 /**
047 * /kr-krad/kradsampleapp?viewId=Demo-Breadcrumbs-View
048 */
049 public static final String TARGET_URL_CHECK = "/kr-krad/kradsampleapp?viewId=Demo-Breadcrumbs-View";
050
051 @Override
052 protected String getBookmarkUrl() {
053 return BOOKMARK_URL;
054 }
055
056 @Override
057 protected void navigate() throws Exception {
058 navigateToLibraryDemo("Widgets", "Breadcrumbs");
059 }
060
061 protected void testWidgetsBreadcrumbDefault() throws Exception {
062 waitAndClickByLinkText("Default Breadcrumbs");
063 assertNewWindow("1");
064 }
065
066 protected void testWidgetsBreadcrumbParentLocation() throws Exception {
067 waitAndClickByLinkText("ParentLocation");
068 waitAndClickByLinkText("Home ParentLocation");
069 assertNewWindow("2");
070 }
071
072 protected void testWidgetsBreadcrumbParentLocationChain() throws Exception {
073 waitAndClickByLinkText("ParentLocation Chain");
074 waitAndClickByLinkText("ParentLocation Chain/Trail");
075 assertNewWindow("3");
076 }
077
078 protected void testWidgetsBreadcrumbParentLocationPage() throws Exception {
079 waitAndClickByLinkText("ParentLocation Page");
080 waitAndClickByLinkText("ParentLocation View and Page");
081 assertNewWindow("4");
082 }
083
084 protected void testWidgetsBreadcrumbPreViewAndPrePage() throws Exception {
085 waitAndClickByLinkText("preView and prePage");
086 waitAndClickByLinkText("preView and prePage breadcrumbs");
087 assertNewWindow("5");
088 }
089
090 protected void testWidgetsBreadcrumbBreadcrumbLabel() throws Exception {
091 waitAndClickByLinkText("Breadcrumb Label");
092 waitAndClickByLinkText("Override Breadcrumb Label");
093 assertNewWindow("6");
094 }
095
096 protected void testWidgetsBreadcrumbHomewardPath() throws Exception {
097 waitAndClickByLinkText("Homeward Path");
098 waitAndClickByLinkText("Homeward Path Breadcrumbs");
099 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 }