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