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 /**
023 * @author Kuali Rice Team (rice.collab@kuali.org)
024 */
025 public class DemoLibraryWidgetsDisclosureSmokeTest extends DemoLibraryBase {
026
027 /**
028 * /kr-krad/kradsampleapp?viewId=Demo-Disclosure-View&methodToCall=start
029 */
030 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-Disclosure-View&methodToCall=start";
031
032 @Override
033 protected String getBookmarkUrl() {
034 return BOOKMARK_URL;
035 }
036
037 @Override
038 protected void navigate() throws Exception {
039 navigateToLibraryDemo("Widgets", "Disclosure");
040 }
041
042 protected void testWidgetsDisclosureDefault() throws Exception {
043 waitAndClickByLinkText("Default");
044 WebElement exampleDiv = navigateToExample("Demo-Disclosure-Example1");
045
046 //first example
047 WebElement disclosure1 = findElement(By.id("u100085_disclosureContent"), exampleDiv);
048
049 if (!disclosure1.isDisplayed()) {
050 fail("First disclosure not displayed");
051 }
052
053 waitAndClickByLinkText("Disclosure Section");
054 Thread.sleep(1000);
055
056 if (disclosure1.isDisplayed()) {
057 fail("First disclosure did not close");
058 }
059
060 //second example
061 WebElement disclosure2 = findElement(By.id("u100105_disclosureContent"), exampleDiv);
062
063 if (!disclosure2.isDisplayed()) {
064 fail("Second disclosure not displayed");
065 }
066
067 waitAndClickByLinkText("Predefined Disclosure Section");
068 Thread.sleep(1000);
069
070 if (disclosure2.isDisplayed()) {
071 fail("Second disclosure did not close");
072 }
073 }
074
075 protected void testWidgetsDisclosureClosed() throws Exception {
076 waitAndClickByLinkText("Closed");
077 WebElement exampleDiv = navigateToExample("Demo-Disclosure-Example2");
078 WebElement disclosure = findElement(By.cssSelector(".uif-disclosureContent"), exampleDiv);
079
080 if (disclosure.isDisplayed()) {
081 fail("Disclosure did not default closed");
082 }
083
084 waitAndClickByLinkText("Default Closed Section");
085 Thread.sleep(1000);
086
087 if (!disclosure.isDisplayed()) {
088 fail("Disclosure did not open");
089 }
090 }
091
092 @Test
093 public void testWidgetsDisclosureBookmark() throws Exception {
094 testWidgetsDisclosureDefault();
095 testWidgetsDisclosureClosed();
096
097 driver.close();
098 passed();
099 }
100
101 @Test
102 public void testWidgetsDisclosureNav() throws Exception {
103 testWidgetsDisclosureDefault();
104 testWidgetsDisclosureClosed();
105
106 driver.close();
107 passed();
108 }
109 }