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 testCollectionSequenceExamples() throws Exception {
051 changeSequenceView();
052 }
053
054 private boolean isOptionSelected(String dropDownName, String optionValue) {
055 WebElement select = driver.findElement(By.name(dropDownName));
056 List<WebElement> options = select.findElements(By.tagName("option"));
057 for (WebElement option: options) {
058 if (option.getAttribute("selected")!=null) {
059 return true;
060 }
061 }
062 return false;
063 }
064
065 @Test
066 public void testCollectionSequenceBookmark() throws Exception {
067 testCollectionSequenceExamples();
068 passed();
069 }
070
071 @Test
072 public void testCollectionSequenceNav() throws Exception {
073 testCollectionSequenceExamples();
074 passed();
075 }
076 }