001 /* 002 * Copyright 2006-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 017 package edu.samplu.krad.demo.uif.library; 018 019 import com.thoughtworks.selenium.SeleneseTestBase; 020 import edu.samplu.common.WebDriverLegacyITBase; 021 import org.kuali.rice.krad.uif.UifConstants; 022 import org.openqa.selenium.By; 023 import org.openqa.selenium.WebElement; 024 025 /** 026 * @author Kuali Rice Team (rice.collab@kuali.org) 027 */ 028 public abstract class DemoLibraryITBase extends WebDriverLegacyITBase { 029 030 /** 031 * Automatically selects the library link and then navigate to the appropriate demo in the category 032 * specified 033 * 034 * @param libraryMenuCategoryName the category to select in the navigation accordion by name (text) 035 * @param demoItemName the demo link by name (text) 036 * @throws Exception 037 */ 038 public void navigateToLibraryDemo(String libraryMenuCategoryName, String demoItemName) throws Exception{ 039 waitAndClickById("Demo-LibraryLink", ""); 040 waitAndClickByLinkText(libraryMenuCategoryName); 041 waitAndClickByLinkText(demoItemName); 042 } 043 044 /** 045 * Automatically selects and returns the appropriate example div by the id specified, works with demos 046 * that use either the tab navigation or dropdown navigation for their example navigation; 047 * if the example by id is already selected, this method still verifies that the group is visible and does not fail 048 * 049 * @param exampleId the id of the example 050 * @return the WebElement representing the example group 051 * @throws Exception 052 */ 053 public WebElement navigateToExample(String exampleId) throws Exception{ 054 WebElement exampleTab; 055 String tabId = "#" + exampleId + UifConstants.IdSuffixes.TAB; 056 057 if(isVisibleById("ComponentLibrary-TabGroup_tabList") 058 && isElementPresentByDataAttributeValue(UifConstants.DataAttributes.TAB_FOR, exampleId)){ 059 WebElement menuItem = getElementByDataAttributeValue(UifConstants.DataAttributes.TAB_FOR, exampleId); 060 menuItem.findElement(By.cssSelector("a")).click(); 061 062 waitForElementPresent(tabId); 063 waitForElementVisible(tabId, ""); 064 } 065 else if(isElementPresent(By.cssSelector("#Demo-LargeExampleDropdown_control"))){ 066 selectOption(By.cssSelector("#Demo-LargeExampleDropdown_control"), exampleId); 067 waitForElementPresent(tabId); 068 waitForElementVisible(tabId, ""); 069 driver.findElement(By.cssSelector(tabId)); 070 } 071 else{ 072 SeleneseTestBase.fail(exampleId + " does not exist as an example for this demo"); 073 } 074 075 exampleTab = driver.findElement(By.cssSelector(tabId)); 076 return exampleTab; 077 } 078 }