View Javadoc

1   /**
2    * Copyright 2005-2013 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.samplu.krad.library.controls;
17  
18  import org.junit.Test;
19  
20  import org.kuali.rice.testtools.selenium.Failable;
21  import org.kuali.rice.testtools.selenium.ITUtil;
22  import org.kuali.rice.testtools.selenium.SmokeTestBase;
23  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
24  
25  /**
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   */
28  public class DemoLibraryControlTextSmokeTest extends SmokeTestBase {
29  
30      /**
31       * /kr-krad/kradsampleapp?viewId=Demo-TextControl-View&methodToCall=start
32       */
33      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-TextControl-View&methodToCall=start";
34  
35      /**
36       * //div[@id='Demo-TextControl-Example1']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField1']
37       */
38      private static final String DEFAULT_TXT_FIELD_XPATH = "//div[@id='Demo-TextControl-Example1']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField1']";
39      
40      /**
41       * //div[@id='Demo-TextControl-Example2']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField2']
42       */
43      private static final String SIZE_TXT_FIELD_XPATH = "//div[@id='Demo-TextControl-Example2']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField2']";
44      
45      /**
46       * //div[@id='Demo-TextControl-Example3']/div[@class='uif-verticalBoxLayout clearfix']/div/a[@title='Expand']
47       */
48      private static final String EXPAND_TXT_FIELD_XPATH = "//div[@id='Demo-TextControl-Example3']/div[@class='uif-verticalBoxLayout clearfix']/div/a[@title='Expand']";
49      
50      /**
51       * //div[@id='Demo-TextControl-Example4']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField4' and @disabled='disabled']
52       */
53      private static final String DISABLED_TXT_FIELD_XPATH = "//div[@id='Demo-TextControl-Example4']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField4' and @disabled='disabled']";
54      
55      /**
56       * //div[@id='Demo-TextControl-Example7']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField5' and @placeholder='watermark text ']
57       */
58      private static final String WATERMARK_TXT_FIELD_XPATH = "//div[@id='Demo-TextControl-Example7']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField5' and @placeholder='watermark text ']";
59  
60      /**
61       * //div[@id='Demo-TextControl-Example8']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField7' and @disabled='disabled']
62       */
63      private static final String DISABLE_ON_KEY_EVENT_TXT_FIELD_XPATH_BEFORE = "//div[@id='Demo-TextControl-Example8']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField7' and @disabled='disabled']";
64      
65      /**
66       * //div[@id='Demo-TextControl-Example8']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField7']
67       */
68      private static final String DISABLE_ON_KEY_EVENT_TXT_FIELD_XPATH_AFTER = "//div[@id='Demo-TextControl-Example8']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField7']";
69      
70      /**
71       * //div[@id='Demo-TextControl-Example9']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField9' and @disabled='disabled']
72       */
73      private static final String ENABLE_WHEN_CHANGED_TXT_FIELD_XPATH_BEFORE = "//div[@id='Demo-TextControl-Example9']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField9' and @disabled='disabled']";
74      
75      /**
76       * //div[@id='Demo-TextControl-Example9']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField9']
77       */
78      private static final String ENABLE_WHEN_CHANGED_TXT_FIELD_XPATH_AFTER = "//div[@id='Demo-TextControl-Example9']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField9']";
79      
80      /**
81       * //div[@id='Demo-TextControl-Example10']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField11' and @disabled='disabled']
82       */
83      private static final String DISABLE_WHEN_CHANGED_TXT_FIELD_XPATH_AFTER = "//div[@id='Demo-TextControl-Example10']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField11' and @disabled]";
84      
85      /**
86       * //div[@id='Demo-TextControl-Example10']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField11']
87       */
88      private static final String DISABLE_WHEN_CHANGED_TXT_FIELD_XPATH_BEFORE = "//div[@id='Demo-TextControl-Example10']/div[@class='uif-verticalBoxLayout clearfix']/div/input[@type='text' and @name='inputField11']";
89      
90      @Override
91      protected String getBookmarkUrl() {
92          return BOOKMARK_URL;
93      }
94  
95      @Override
96      protected void navigate() throws Exception {
97          waitAndClickById("Demo-LibraryLink", "");
98          waitAndClickByLinkText("Controls");
99          waitAndClickByLinkText("Text");
100     }
101 
102     protected void testLibraryControlTextDefault() throws Exception {
103         waitForElementPresentByXpath(DEFAULT_TXT_FIELD_XPATH);
104         waitAndTypeByXpath(DEFAULT_TXT_FIELD_XPATH,"HiText!");
105     }
106     
107     protected void testLibraryControlTextSize() throws Exception {
108         waitAndClickByLinkText("Size");
109         waitForElementPresentByXpath(SIZE_TXT_FIELD_XPATH);
110         waitAndTypeByXpath(SIZE_TXT_FIELD_XPATH,"HiTextHiTextHiTextHiTextHiTextHiTextHiTextHiTextHiTextHiText");
111     }
112     
113     protected void testLibraryControlTextExpand() throws Exception {
114         waitAndClickByLinkText("Text expand");
115         waitForElementPresentByXpath(EXPAND_TXT_FIELD_XPATH);
116     }
117     
118     protected void testLibraryControlTextDisabled() throws Exception {
119         waitAndClickByLinkText("Disabled");
120         waitForElementPresentByXpath(DISABLED_TXT_FIELD_XPATH);
121     }
122     
123     protected void testLibraryControlTextWatermarkText() throws Exception {
124         waitAndClickByLinkText("WatermarkText");
125         waitForElementPresentByXpath(WATERMARK_TXT_FIELD_XPATH);
126     }
127 
128     protected void testLibraryControlTextDisableOnKeyEvent() throws Exception {
129         waitAndClickByLinkText("Disable on Key event");
130         assertElementPresentByXpath(DISABLE_ON_KEY_EVENT_TXT_FIELD_XPATH_BEFORE);
131         waitAndTypeByName("inputField6","a");
132         assertElementPresentByXpath(DISABLE_ON_KEY_EVENT_TXT_FIELD_XPATH_AFTER);
133     }
134     
135     protected void testLibraryControlTextEnableWhenChanged() throws Exception {
136         waitAndClickByLinkText("Enable when changed");
137         assertElementPresentByXpath(ENABLE_WHEN_CHANGED_TXT_FIELD_XPATH_BEFORE);
138         waitAndTypeByName("inputField8","a");
139         waitAndClickByLinkText("Usage");
140         assertElementPresentByXpath(ENABLE_WHEN_CHANGED_TXT_FIELD_XPATH_AFTER);
141     }
142     
143     protected void testLibraryControlTextDisableWhenChanged() throws Exception {
144         waitAndClickByLinkText("Disable when changed");
145         assertElementPresentByXpath(DISABLE_WHEN_CHANGED_TXT_FIELD_XPATH_BEFORE);
146         waitAndTypeByName("inputField10","a");
147         waitAndClickByLinkText("Usage");
148         assertElementPresentByXpath(DISABLE_WHEN_CHANGED_TXT_FIELD_XPATH_AFTER);
149     }
150     
151     @Test
152     public void testControlTextBookmark() throws Exception {
153         testLibraryControlTextDefault();
154         testLibraryControlTextSize();
155         testLibraryControlTextExpand();
156         testLibraryControlTextDisabled();
157         testLibraryControlTextWatermarkText();
158         testLibraryControlTextDisableOnKeyEvent();
159         testLibraryControlTextEnableWhenChanged();
160         testLibraryControlTextDisableWhenChanged();
161         passed();
162     }
163 
164     @Test
165     public void testControlTextNav() throws Exception {
166         testLibraryControlTextDefault();
167         testLibraryControlTextSize();
168         testLibraryControlTextExpand();
169         testLibraryControlTextDisabled();
170         testLibraryControlTextWatermarkText();
171         testLibraryControlTextDisableOnKeyEvent();
172         testLibraryControlTextEnableWhenChanged();
173         testLibraryControlTextDisableWhenChanged();
174         passed();
175     }  
176 }