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