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 testCollectionSequenceExamples() throws Exception {
51          changeSequenceView();
52      }
53  
54      private boolean isOptionSelected(String dropDownName, String optionValue) {
55          WebElement select = driver.findElement(By.name(dropDownName));
56          List<WebElement> options = select.findElements(By.tagName("option"));
57          for (WebElement option: options) {
58              if (option.getAttribute("selected")!=null) {
59                  return true;
60              }
61          }
62          return false;
63      }
64  
65      @Test
66      public void testCollectionSequenceBookmark() throws Exception {
67          testCollectionSequenceExamples();
68          passed();
69      }
70  
71      @Test
72      public void testCollectionSequenceNav() throws Exception {
73          testCollectionSequenceExamples();
74          passed();
75      }
76  }