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     */
016    package edu.sampleu.krad.screenelement;
017    
018    import org.junit.Test;
019    import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
020    import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
021    import org.kuali.rice.testtools.selenium.WebDriverUtils;
022    
023    /**
024     * @author Kuali Rice Team (rice.collab@kuali.org)
025     */
026    public 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            waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
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            waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
082        }
083        
084        private void validateDialogWithHTML() throws Exception {
085            waitForElementPresentByXpath("//form[@id='kualiLightboxForm']/b");
086            waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
087        }
088        
089        private void validateDialogWithPredefinedOkCancel() throws Exception {
090            waitForTextPresent("Please Confirm to Continue");
091            waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
092        }
093        
094        private void validateDialogWithRadioButton() throws Exception {
095            waitForElementPresentByXpath("//div[@id='sampleRadioButtonDialog']/div/fieldset/span/input[@type='radio']");
096            waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
097        }
098        
099        private void validateDialogWithProgressiveRendering() throws Exception {
100            waitForTextPresent("This is always displayed:");
101            waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
102        }
103        
104        private void validateDialogWithHiddenImage() throws Exception {
105            waitForElementPresentByXpath("//img[@src='/krad/images/computer_programming.jpg']");
106            waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
107        }
108        
109        private void validateDialogWithFormUrl() throws Exception {
110            waitForElementPresentByXpath("//iframe[@class='fancybox-iframe']");
111            waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
112        }
113        
114        private void validateDialogWithClientAjax() throws Exception {
115            waitForTextPresent("Please select from the values below");
116            waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
117        }
118        
119        private void validateDialogWithRegularGroup() throws Exception {
120            waitForTextPresent("This group does not inherit from Uif-DialogGroup:");
121            waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']"); 
122        }
123        
124        private void validateDialogWithExpression() throws Exception {
125            waitForTextPresent("Mark as Ready for Scheduling");
126            waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']"); 
127        }
128        
129        private void validateDialogWithExtended() throws Exception {
130            waitForElementPresentByXpath("//input[@name='field5']");
131            waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']"); 
132        }
133        
134        private void validateDialogWithDisplayResponseInLightBox() throws Exception {
135            waitForTextPresent("This group does not inherit from Uif-DialogGroup:");
136            waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']"); 
137        }
138        
139        @Test
140        public void testDialogTestViewBookmark() throws Exception {
141            testDialogTestView();
142            passed();
143        }
144    
145        @Test
146        public void testDialogTestViewNav() throws Exception {
147            testDialogTestView();
148            passed();
149        }
150    }