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 com.thoughtworks.selenium.SeleneseTestBase;
19  import edu.samplu.krad.demo.uif.library.DemoLibraryBase;
20  import org.junit.Test;
21  import edu.samplu.common.SmokeTestBase;
22  import org.openqa.selenium.By;
23  import org.openqa.selenium.WebElement;
24  
25  /**
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   */
28  public class DemoLibraryWidgetsDisclosureSmokeTest extends DemoLibraryBase {
29  
30      /**
31       * /kr-krad/kradsampleapp?viewId=Demo-Disclosure-View&methodToCall=start
32       */
33      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-Disclosure-View&methodToCall=start";
34  
35      @Override
36      protected String getBookmarkUrl() {
37          return BOOKMARK_URL;
38      }
39  
40      @Override
41      protected void navigate() throws Exception {
42          waitAndClickById("Demo-LibraryLink", "");
43          waitAndClickByLinkText("Widgets");
44          waitAndClickByLinkText("Disclosure");
45      }
46  
47      protected void testWidgetsDisclosureDefault() throws Exception {
48          waitAndClickByLinkText("Default");
49          WebElement exampleDiv = navigateToExample("Demo-Disclosure-Example1");
50  
51          //first example
52          WebElement disclosure1 = findElement(By.id("u100085_disclosureContent"), exampleDiv);
53  
54          if (!disclosure1.isDisplayed()) {
55              fail("First disclosure not displayed");
56          }
57  
58          waitAndClickByLinkText("Disclosure Section");
59          Thread.sleep(1000);
60  
61          if (disclosure1.isDisplayed()) {
62              fail("First disclosure did not close");
63          }
64  
65          //second example
66          WebElement disclosure2 = findElement(By.id("u100105_disclosureContent"), exampleDiv);
67  
68          if (!disclosure2.isDisplayed()) {
69              fail("Second disclosure not displayed");
70          }
71  
72          waitAndClickByLinkText("Predefined Disclosure Section");
73          Thread.sleep(1000);
74  
75          if (disclosure2.isDisplayed()) {
76              fail("Second disclosure did not close");
77          }
78      }
79  
80      protected void testWidgetsDisclosureClosed() throws Exception {
81          waitAndClickByLinkText("Closed");
82          WebElement exampleDiv = navigateToExample("Demo-Disclosure-Example2");
83          WebElement disclosure = findElement(By.cssSelector(".uif-disclosureContent"), exampleDiv);
84  
85          if (disclosure.isDisplayed()) {
86              fail("Disclosure did not default closed");
87          }
88  
89          waitAndClickByLinkText("Default Closed Section");
90          Thread.sleep(1000);
91  
92          if (!disclosure.isDisplayed()) {
93              fail("Disclosure did not open");
94          }
95      }
96  
97      @Test
98      public void testWidgetsDisclosureBookmark() throws Exception {
99          testWidgetsDisclosureDefault();
100         testWidgetsDisclosureClosed();
101 
102         driver.close();
103         passed();
104     }
105 
106     @Test
107     public void testWidgetsDisclosureNav() throws Exception {
108         testWidgetsDisclosureDefault();
109         testWidgetsDisclosureClosed();
110 
111         driver.close();
112         passed();
113     }
114 }