View Javadoc
1   /**
2    * Copyright 2005-2014 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.sampleu.krad.screenelement;
17  
18  import org.junit.Test;
19  import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
20  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21  import org.kuali.rice.testtools.selenium.WebDriverUtils;
22  
23  /**
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class DialogTestViewAft extends WebDriverLegacyITBase {
27  
28      /**
29       * /kr-krad/dialog-configuration-test?viewId=DialogTestView&methodToCall=start
30       */
31      public static final String BOOKMARK_URL ="/kr-krad/dialog-configuration-test?viewId=DialogTestView&methodToCall=start";
32  
33      @Override
34      protected String getBookmarkUrl() {
35          return BOOKMARK_URL;
36      }
37  
38      @Override
39      protected void navigate() throws InterruptedException {
40          waitAndClickKRAD();
41          waitAndClickByLinkText("Dialog Test View");
42          switchToWindow("Kuali :: Dialog Test View");
43      }
44      
45      private void testDialogTestView() throws Exception{
46          waitAndClickButtonByText("Lightbox from hidden group");
47          validateSelectAuthorDialog();
48          waitAndClickButtonByText("Lightbox from hidden group with overrides");
49          validateSelectAuthorDialog();
50          waitAndClickButtonByText("Lightbox from HTML");
51          validateDialogWithHTML();
52          waitAndClickButtonByText("Predefined OK/Cancel");
53          validateDialogWithPredefinedOkCancel();
54          waitAndClickButtonByText("Radio Buttons");
55          validateDialogWithRadioButton();
56          waitAndClickButtonByText("Lightbox from hidden group with progressive rendering");
57          validateDialogWithProgressiveRendering();
58          waitAndClickButtonByText("Lightbox from hidden image");
59          validateDialogWithHiddenImage();
60          waitAndClickButtonByText("Lightbox from URL");
61          validateDialogWithFormUrl();
62          waitAndClickButtonByText("Client Ajax Dialog");
63          validateDialogWithClientAjax();
64          waitAndClickButtonByText("Regular Group");
65          validateDialogWithRegularGroup();
66          waitAndClickButtonByText("Expression dialog");
67          validateDialogWithExpression();
68          waitAndClickButtonByText("Extended Dialog");
69          validateDialogWithExtended();
70          waitAndClickButtonByText("Displays Response in LightBox");
71          validateDialogWithDisplayResponseInLightBox();
72      }
73      
74      private void validateSelectAuthorDialog() throws Exception {
75          waitForElementPresentByXpath("//div[@class='fancybox-skin']/div/div/form/section/header/h3");
76          waitForElementPresentByXpath("//div[@class='fancybox-skin']/div/div/form/section/div/p");
77          waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
78      }
79      
80      private void validateDialogWithHTML() throws Exception {
81          waitForElementPresentByXpath("//form[@id='kualiLightboxForm']/b");
82          waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
83      }
84      
85      private void validateDialogWithPredefinedOkCancel() throws Exception {
86          waitForTextPresent("Please Confirm to Continue");
87          waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
88      }
89      
90      private void validateDialogWithRadioButton() throws Exception {
91          waitForElementPresentByXpath("//div[@id='sampleRadioButtonDialog']/div/fieldset/span/input[@type='radio']");
92          waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
93      }
94      
95      private void validateDialogWithProgressiveRendering() throws Exception {
96          waitForTextPresent("This is always displayed:");
97          waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
98      }
99      
100     private void validateDialogWithHiddenImage() throws Exception {
101         waitForElementPresentByXpath("//img[@src='/krad/images/computer_programming.jpg']");
102         waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
103     }
104     
105     private void validateDialogWithFormUrl() throws Exception {
106         waitForElementPresentByXpath("//iframe[@class='fancybox-iframe']");
107         waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
108     }
109     
110     private void validateDialogWithClientAjax() throws Exception {
111         waitForTextPresent("Please select from the values below");
112         waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']");
113     }
114     
115     private void validateDialogWithRegularGroup() throws Exception {
116         waitForTextPresent("This group does not inherit from Uif-DialogGroup:");
117         waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']"); 
118     }
119     
120     private void validateDialogWithExpression() throws Exception {
121         waitForTextPresent("Mark as Ready for Scheduling");
122         waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']"); 
123     }
124     
125     private void validateDialogWithExtended() throws Exception {
126         waitForElementPresentByXpath("//input[@name='field5']");
127         waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']"); 
128     }
129     
130     private void validateDialogWithDisplayResponseInLightBox() throws Exception {
131         waitForTextPresent("This group does not inherit from Uif-DialogGroup:");
132         waitAndClickByXpath("//a[@class='fancybox-item fancybox-close']"); 
133     }
134     
135     @Test
136     public void testDialogTestViewBookmark() throws Exception {
137         testDialogTestView();
138         passed();
139     }
140 
141     @Test
142     public void testDialogTestViewNav() throws Exception {
143         testDialogTestView();
144         passed();
145     }
146 }