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.compview;
017
018 import com.thoughtworks.selenium.SeleneseTestBase;
019 import edu.samplu.common.SmokeTestBase;
020 import org.junit.Test;
021
022 import java.util.Arrays;
023 import java.util.Collections;
024
025 /**
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028 public class BreadcrumbSmokeTest extends SmokeTestBase {
029
030 /**
031 * /kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page3
032 */
033 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&pageId=UifCompView-Page1";
034
035 /**
036 * //div[@class='uif-breadcrumbSiblingContent']//div[@class='uif-inputField']//ul[@class='uif-optionList']
037 */
038 public static final String SECOND_BREADCRUMB_NAV_XPATH = "//div[@class='uif-breadcrumbSiblingContent']//div[@class='uif-inputField']//ul[@class='uif-optionList']";
039
040 /**
041 * (//a[@class='uif-breadcrumbSiblingLink'])[2]
042 * Not final as it needs to be overwritten for the Demo Breadcrumbs smoke test
043 */
044 public static final String SECOND_DOWN_TRIANGLE_XPATH = "(//a[@class='uif-breadcrumbSiblingLink'])[2]";
045
046 String[][] selectAsserts = {{"UifCompView", "Uif Components"}};
047
048 int[] breadcrumbOrderIndexes = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1};
049
050 @Override
051 protected String getBookmarkUrl() {
052 return BOOKMARK_URL;
053 }
054
055 protected String getTriangleXpath() {
056 return SECOND_DOWN_TRIANGLE_XPATH;
057 }
058
059 protected void navigate() throws Exception {
060 waitAndClickKRAD();
061 waitAndClickByXpath(KITCHEN_SINK_XPATH);
062 switchToWindow(KUALI_UIF_COMPONENTS_WINDOW_XPATH);
063 }
064
065 protected void testBreadcrumb(int pageNumber) throws Exception {
066 // <ul id="u13_control" class="uif-optionList" data-control_for="u13" tabindex="0"><li class="uif-optionList-item uif-optionList-selectedItem"><a href="http://env1.rice.kuali.org/kr-krad/uicomponents?methodToCall=start&pageId=UifCompView-Page1&viewId=UifCompView" data-key="UifCompView-Page1">
067 // Input Fields and Controls
068 // </a></li>
069 // <li class="uif-optionList-item"><a href="http://env1.rice.kuali.org/kr-krad/uicomponents?methodToCall=start&pageId=UifCompView-Page2&viewId=UifCompView" data-key="UifCompView-Page2">
070 // Other Fields
071 // </a></li>
072 // etc.
073 SeleneseTestBase.assertFalse(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH));
074 // The second ▼
075 waitAndClickByXpath(getTriangleXpath());
076 Thread.sleep(100);
077 SeleneseTestBase.assertTrue(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH));
078 waitAndClickByXpath(getTriangleXpath());
079 SeleneseTestBase.assertFalse(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH));
080 waitAndClickByXpath(getTriangleXpath());
081
082 // The Second selection of the second ▼
083 // you can't just click by link text as the same clickable text is on the left navigation.
084 waitAndClickByXpath(SECOND_BREADCRUMB_NAV_XPATH +"/li[" + pageNumber + "]/a");
085 waitForElementPresentById("TopLink" + pageNumber); // bottom jump to top link
086 driver.getCurrentUrl().contains("pageId=UifCompView-Page" + pageNumber);
087 }
088
089 protected void testBreadcrumbs() throws Exception {
090 for (int i = 0, s = breadcrumbOrderIndexes.length; i < s; i++) {
091 testBreadcrumb(breadcrumbOrderIndexes[i]);
092 }
093 }
094
095 protected void testBreadcrumbsShuffled() throws Exception {
096 int[] copiedBreadcrumbOrderIndex = Arrays.copyOf(breadcrumbOrderIndexes, breadcrumbOrderIndexes.length);
097
098 Collections.shuffle(Arrays.asList(copiedBreadcrumbOrderIndex));
099 for (int i = 0, s = copiedBreadcrumbOrderIndex.length; i < s; i++) {
100 testBreadcrumb(copiedBreadcrumbOrderIndex[i]);
101 }
102 }
103
104 @Test
105 public void testBreadcrumbBookmark() throws Exception {
106 testBreadcrumbs();
107 passed();
108 }
109
110 @Test
111 public void testBreadcrumbShuffledBookmark() throws Exception {
112 testBreadcrumbsShuffled();
113 passed();
114 }
115
116 @Test
117 public void testBreadcrumbNav() throws Exception {
118 testBreadcrumbs();
119 passed();
120 }
121
122 @Test
123 public void testBreadcrumbShuffledNav() throws Exception {
124 testBreadcrumbsShuffled();
125 passed();
126 }
127 }