001/**
002 * Copyright 2005-2014 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 */
016package edu.sampleu.krad.screenelement;
017
018import org.junit.Test;
019import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
020import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
021import org.kuali.rice.testtools.selenium.WebDriverUtils;
022
023/**
024 * @author Kuali Rice Team (rice.collab@kuali.org)
025 */
026public class DialogTestViewAft extends WebDriverLegacyITBase {
027
028    /**
029     * /kr-krad/dialog-configuration-test?viewId=DialogTestView&methodToCall=start
030     */
031    public static final String BOOKMARK_URL ="/kr-krad/dialog-configuration-test?viewId=DialogTestView&methodToCall=start";
032
033    @Override
034    protected String getBookmarkUrl() {
035        return BOOKMARK_URL;
036    }
037
038    @Override
039    protected void navigate() throws InterruptedException {
040        waitAndClickKRAD();
041        waitAndClickByLinkText("Dialog Test View");
042        switchToWindow("Kuali :: Dialog Test View");
043    }
044    
045    private void testDialogTestView() throws Exception{
046        waitAndClickButtonByText("Lightbox from hidden group");
047        validateSelectAuthorDialog();
048        waitAndClickButtonByText("Lightbox from hidden group with overrides");
049        validateSelectAuthorDialog();
050        waitAndClickButtonByText("Lightbox from HTML");
051        validateDialogWithHTML();
052        waitAndClickButtonByText("Predefined OK/Cancel");
053        validateDialogWithPredefinedOkCancel();
054        waitAndClickButtonByText("Radio Buttons");
055        validateDialogWithRadioButton();
056        waitAndClickButtonByText("Lightbox from hidden group with progressive rendering");
057        validateDialogWithProgressiveRendering();
058        waitAndClickButtonByText("Lightbox from hidden image");
059        validateDialogWithHiddenImage();
060        waitAndClickButtonByText("Lightbox from URL");
061        validateDialogWithFormUrl();
062        waitAndClickButtonByText("Client Ajax Dialog");
063        validateDialogWithClientAjax();
064        waitAndClickButtonByText("Regular Group");
065        validateDialogWithRegularGroup();
066        waitAndClickButtonByText("Expression dialog");
067        validateDialogWithExpression();
068        waitAndClickButtonByText("Extended Dialog");
069        validateDialogWithExtended();
070        waitAndClickButtonByText("Displays Response in LightBox");
071        validateDialogWithDisplayResponseInLightBox();
072        waitAndClickButtonByText("Tell Me A Story");
073        waitAndCloseDialog();
074        waitAndClickButtonByText("Close");
075        waitAndClickLinkContainingText("Cancel");
076    }
077    
078    private void validateSelectAuthorDialog() throws Exception {
079        waitForElementPresentByXpath("//div[@class='fancybox-skin']/div/div/form/section/header/h3");
080        waitForElementPresentByXpath("//div[@class='fancybox-skin']/div/div/form/section/div/p");
081        waitAndCloseDialog();
082    }
083
084    private void waitAndCloseDialog() throws InterruptedException {
085        jGrowl("Click Dialog Close");
086        waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
087    }
088
089    private void validateDialogWithHTML() throws Exception {
090        waitForElementPresentByXpath("//form[@id='kualiLightboxForm']/b");
091        waitAndCloseDialog();
092    }
093    
094    private void validateDialogWithPredefinedOkCancel() throws Exception {
095        waitForTextPresent("Please Confirm to Continue");
096        waitAndCloseDialog();
097    }
098    
099    private void validateDialogWithRadioButton() throws Exception {
100        waitForElementPresentByXpath("//div[@id='sampleRadioButtonDialog']/div/fieldset/span/input[@type='radio']");
101        waitAndCloseDialog();
102    }
103    
104    private void validateDialogWithProgressiveRendering() throws Exception {
105        waitForTextPresent("This is always displayed:");
106        waitAndCloseDialog();
107    }
108    
109    private void validateDialogWithHiddenImage() throws Exception {
110        waitForElementPresentByXpath("//img[@src='/krad/images/computer_programming.jpg']");
111        waitAndCloseDialog();
112    }
113    
114    private void validateDialogWithFormUrl() throws Exception {
115        waitForElementPresentByXpath("//iframe[@class='fancybox-iframe']");
116        waitAndCloseDialog();
117    }
118    
119    private void validateDialogWithClientAjax() throws Exception {
120        waitForTextPresent("Please select from the values below");
121        waitAndCloseDialog();
122    }
123    
124    private void validateDialogWithRegularGroup() throws Exception {
125        waitForTextPresent("This group does not inherit from Uif-DialogGroup:");
126        waitAndCloseDialog();
127    }
128    
129    private void validateDialogWithExpression() throws Exception {
130        waitForTextPresent("Mark as Ready for Scheduling");
131        waitAndCloseDialog();
132    }
133    
134    private void validateDialogWithExtended() throws Exception {
135        waitForElementPresentByXpath("//input[@name='field5']");
136        waitAndCloseDialog();
137    }
138    
139    private void validateDialogWithDisplayResponseInLightBox() throws Exception {
140        waitForTextPresent("This group does not inherit from Uif-DialogGroup:");
141        waitAndCloseDialog();
142    }
143    
144    @Test
145    public void testDialogTestViewBookmark() throws Exception {
146        testDialogTestView();
147        passed();
148    }
149
150    @Test
151    public void testDialogTestViewNav() throws Exception {
152        testDialogTestView();
153        passed();
154    }
155}