001/** 002 * Copyright 2005-2014 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 */ 016package org.kuali.rice.testtools.selenium.breadcrumb; 017 018import org.junit.Test; 019import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase; 020 021import java.util.Arrays; 022import java.util.Collections; 023 024/** 025 * @author Kuali Rice Team (rice.collab@kuali.org) 026 */ 027public abstract class BreadcrumbAftBase extends WebDriverLegacyITBase { 028 029 /** 030 * //div[@class='uif-breadcrumbSiblingContent']//div[@class='uif-inputField']//ul[@class='uif-optionList'] 031 */ 032 public static final String SECOND_BREADCRUMB_NAV_XPATH = "//div[@class='uif-breadcrumbSiblingContent']//div[@class='uif-inputField']//ul[@class='uif-optionList']"; 033 034 /** 035 * (//a[@class='uif-breadcrumbSiblingLink'])[2] 036 */ 037 public static final String SECOND_DOWN_TRIANGLE_XPATH = "(//a[@class='uif-breadcrumbSiblingLink'])[2]"; 038 039 String[][] selectAsserts = {{"UifCompView", "Uif Components"}}; 040 041 int[] breadcrumbOrderIndexes = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1}; 042 043 protected String getTriangleXpath() { 044 return SECOND_DOWN_TRIANGLE_XPATH; 045 } 046 047 protected void testBreadcrumb(int pageNumber) throws Exception { 048 // <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"> 049 // Input Fields and Controls 050 // </a></li> 051 // <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"> 052 // Other Fields 053 // </a></li> 054 // etc. 055 assertFalse(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH)); 056 // The second ▼ 057 waitAndClickByXpath(getTriangleXpath(), "failed on breadcrumb pageNumber " + pageNumber); 058 Thread.sleep(100); 059 assertTrue(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH)); 060 waitAndClickByXpath(getTriangleXpath()); 061 assertFalse(isVisibleByXpath(SECOND_BREADCRUMB_NAV_XPATH)); 062 waitAndClickByXpath(getTriangleXpath()); 063 064 // The Second selection of the second ▼ 065 // you can't just click by link text as the same clickable text is on the left navigation. 066 waitAndClickByXpath(SECOND_BREADCRUMB_NAV_XPATH +"/li[" + pageNumber + "]/a"); 067 waitForElementPresentById("TopLink" + pageNumber, "Breadcrumb number " + pageNumber + " failure", 30); // bottom jump to top link 068 driver.getCurrentUrl().contains("pageId=UifCompView-Page" + pageNumber); 069 } 070 071 protected void testBreadcrumbs() throws Exception { 072 for (int i = 0, s = breadcrumbOrderIndexes.length; i < s; i++) { 073 testBreadcrumb(breadcrumbOrderIndexes[i]); 074 } 075 } 076 077 protected void testBreadcrumbsShuffled() throws Exception { 078 int[] copiedBreadcrumbOrderIndex = Arrays.copyOf(breadcrumbOrderIndexes, breadcrumbOrderIndexes.length); 079 080 Collections.shuffle(Arrays.asList(copiedBreadcrumbOrderIndex)); 081 for (int i = 0, s = copiedBreadcrumbOrderIndex.length; i < s; i++) { 082 testBreadcrumb(copiedBreadcrumbOrderIndex[i]); 083 } 084 } 085 086 @Test 087 public void testBreadcrumbBookmark() throws Exception { 088 testBreadcrumbs(); 089 passed(); 090 } 091 092 @Test 093 public void testBreadcrumbShuffledBookmark() throws Exception { 094 testBreadcrumbsShuffled(); 095 passed(); 096 } 097 098 @Test 099 public void testBreadcrumbNav() throws Exception { 100 testBreadcrumbs(); 101 passed(); 102 } 103 104 @Test 105 public void testBreadcrumbShuffledNav() throws Exception { 106 testBreadcrumbsShuffled(); 107 passed(); 108 } 109}