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.demo.uif.library;
17  
18  import com.thoughtworks.selenium.SeleneseTestBase;
19  import edu.samplu.krad.demo.uif.library.DemoLibraryBase;
20  import org.junit.Test;
21  import edu.samplu.common.SmokeTestBase;
22  import org.kuali.rice.krad.uif.UifConstants;
23  import org.openqa.selenium.By;
24  import org.openqa.selenium.WebElement;
25  import org.openqa.selenium.interactions.Actions;
26  
27  import java.text.SimpleDateFormat;
28  import java.util.Date;
29  import java.util.List;
30  
31  /**
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class DemoLibraryWidgetsDatePickerSmokeTest extends DemoLibraryBase {
35  
36      /**
37       * /kr-krad/kradsampleapp?viewId=Demo-DatePicker-View&methodToCall=start
38       */
39      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-DatePicker-View&methodToCall=start";
40  
41      @Override
42      protected String getBookmarkUrl() {
43          return BOOKMARK_URL;
44      }
45  
46      @Override
47      protected void navigate() throws Exception {
48          waitAndClickById("Demo-LibraryLink", "");
49          waitAndClickByLinkText("Widgets");
50          waitAndClickByLinkText("DatePicker");
51      }
52  
53      protected void testWidgetsDatePickerDefault() throws Exception {
54  
55          //click on datepicker
56          waitAndClick(By.cssSelector("img.ui-datepicker-trigger"));
57  
58          //select today
59          waitAndClick(By.cssSelector(".ui-datepicker-current"));
60  
61          //make sure today is populated
62          String today = new SimpleDateFormat("MM/dd/yyyy").format(new Date());
63          String populatedDate = driver.findElement(By.id("u100085_control")).getAttribute("value");
64          if (!populatedDate.equals(today)) {
65              fail("DatePicker did not populate correct value.");
66          }
67  
68      }
69  
70      protected void testWidgetsDatePickerWidget() throws Exception {
71          waitAndClickByLinkText(">> Open Library Navigation");
72          waitAndClickByLinkText("Suggest");
73          waitAndClickByLinkText("Tooltip");
74          select(By.id("Demo-LargeExampleDropdown_control"), "Tooltip On Focus");
75  
76          //focus label
77          fireMouseOverEvent(By.id("u100101_label"));
78          Thread.sleep(1000);
79          WebElement tooltipFocusLabel = driver.findElement(By.xpath("//div[@data-for=\"u100101_label\"]")).findElement(
80                  By.className("jquerybubblepopup-innerHtml"));
81          if (!tooltipFocusLabel.isDisplayed()) {
82              fail("Tooltip help for label not displayed.");
83          }
84          if (!tooltipFocusLabel.getText().equals("Click on the text box for a tool tip")) {
85              fail("Incorrect inner html text for label focus tooltip.");
86          }
87  
88          //focus control
89          waitAndClickById("u100101_control");
90          Thread.sleep(1000);
91          WebElement tooltipFocusControl = driver.findElement(By.xpath("//div[@data-for=\"u100101_control\"]"))
92                  .findElement(By.className("jquerybubblepopup-innerHtml"));
93          if (!tooltipFocusControl.isDisplayed()) {
94              fail("Tooltip help for control not displayed.");
95          }
96          if (!tooltipFocusControl.getText().equals("This tooltip appears when the field receives focus")) {
97              fail("Incorrect inner html text for tooltip focus control.");
98          }
99      }
100 
101     @Test
102     public void testWidgetsDatePickerBookmark() throws Exception {
103         testWidgetsDatePickerDefault();
104         driver.close();
105         passed();
106     }
107 
108     @Test
109     public void testWidgetsDatePickerNav() throws Exception {
110         testWidgetsDatePickerDefault();
111         driver.close();
112         passed();
113     }
114 }