View Javadoc

1   /*
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package edu.samplu.krad.demo.uif.library;
17  
18  import org.junit.Test;
19  import org.openqa.selenium.By;
20  import org.openqa.selenium.WebElement;
21  
22  import java.util.List;
23  
24  /**
25   * @author Kuali Rice Team (rice.collab@kuali.org)
26   */
27  public class DemoLibraryCollectionSequenceSmokeTest extends DemoLibraryBase {
28  
29      /**
30       * /kr-krad/kradsampleapp?viewId=Demo-CollectionSequence-View
31       */
32      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-CollectionSequence-View";
33  
34      @Override
35      protected String getBookmarkUrl() {
36          return BOOKMARK_URL;
37      }
38  
39      @Override
40      protected void navigate() throws Exception {
41          navigateToLibraryDemo("Collection Features", "Sequence Column");
42      }
43  
44      protected void changeSequenceView() throws Exception {
45          selectOptionByName("exampleShown","Demo-CollectionSequence-Example2");
46          waitForPageToLoad();
47          assert(isOptionSelected("exampleShown", "Demo-CollectionSequence-Example2"));
48      }
49  
50      protected void changeViewTheme() throws Exception {
51          selectOptionByName("themeName", "Uif-ClassicKnsTheme");
52          waitForPageToLoad();
53          assert(isOptionSelected("themeName","Uif-ClassicKnsTheme"));
54          selectOptionByName("themeName", "Uif-KradTheme");
55          waitForPageToLoad();
56          assert(isOptionSelected("themeName","Uif-KradTheme"));
57      }
58  
59      protected void testCollectionSequenceExamples() throws Exception {
60          changeViewTheme();
61          changeSequenceView();
62      }
63  
64      private boolean isOptionSelected(String dropDownName, String optionValue) {
65          WebElement select = driver.findElement(By.name(dropDownName));
66          List<WebElement> options = select.findElements(By.tagName("option"));
67          for (WebElement option: options) {
68              if (option.getAttribute("selected")!=null) {
69                  return true;
70              }
71          }
72          return false;
73      }
74  
75      @Test
76      public void testCollectionSequenceBookmark() throws Exception {
77          testCollectionSequenceExamples();
78          passed();
79      }
80  
81      @Test
82      public void testCollectionSequenceNav() throws Exception {
83          testCollectionSequenceExamples();
84          passed();
85      }
86  }