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 org.junit.Test; 019 import org.openqa.selenium.By; 020 import org.openqa.selenium.WebElement; 021 022 import java.util.List; 023 024 /** 025 * @author Kuali Rice Team (rice.collab@kuali.org) 026 */ 027 public class DemoLibraryCollectionSequenceSmokeTest extends DemoLibraryBase { 028 029 /** 030 * /kr-krad/kradsampleapp?viewId=Demo-CollectionSequence-View 031 */ 032 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-CollectionSequence-View"; 033 034 @Override 035 protected String getBookmarkUrl() { 036 return BOOKMARK_URL; 037 } 038 039 @Override 040 protected void navigate() throws Exception { 041 navigateToLibraryDemo("Collection Features", "Sequence Column"); 042 } 043 044 protected void changeSequenceView() throws Exception { 045 selectOptionByName("exampleShown","Demo-CollectionSequence-Example2"); 046 waitForPageToLoad(); 047 assert(isOptionSelected("exampleShown", "Demo-CollectionSequence-Example2")); 048 } 049 050 protected void changeViewTheme() throws Exception { 051 selectOptionByName("themeName", "Uif-ClassicKnsTheme"); 052 waitForPageToLoad(); 053 assert(isOptionSelected("themeName","Uif-ClassicKnsTheme")); 054 selectOptionByName("themeName", "Uif-KradTheme"); 055 waitForPageToLoad(); 056 assert(isOptionSelected("themeName","Uif-KradTheme")); 057 } 058 059 protected void testCollectionSequenceExamples() throws Exception { 060 changeViewTheme(); 061 changeSequenceView(); 062 } 063 064 private boolean isOptionSelected(String dropDownName, String optionValue) { 065 WebElement select = driver.findElement(By.name(dropDownName)); 066 List<WebElement> options = select.findElements(By.tagName("option")); 067 for (WebElement option: options) { 068 if (option.getAttribute("selected")!=null) { 069 return true; 070 } 071 } 072 return false; 073 } 074 075 @Test 076 public void testCollectionSequenceBookmark() throws Exception { 077 testCollectionSequenceExamples(); 078 passed(); 079 } 080 081 @Test 082 public void testCollectionSequenceNav() throws Exception { 083 testCollectionSequenceExamples(); 084 passed(); 085 } 086 }