001 /** 002 * Copyright 2005-2013 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.samplu.krad.demo.uif.library; 017 018 import com.thoughtworks.selenium.SeleneseTestBase; 019 import edu.samplu.krad.demo.uif.library.DemoLibraryBase; 020 import org.junit.Test; 021 import edu.samplu.common.SmokeTestBase; 022 import org.kuali.rice.krad.uif.UifConstants; 023 import org.openqa.selenium.By; 024 import org.openqa.selenium.WebElement; 025 import org.openqa.selenium.interactions.Actions; 026 027 import java.text.SimpleDateFormat; 028 import java.util.Date; 029 import java.util.List; 030 031 /** 032 * @author Kuali Rice Team (rice.collab@kuali.org) 033 */ 034 public class DemoLibraryWidgetsDatePickerSmokeTest extends DemoLibraryBase { 035 036 /** 037 * /kr-krad/kradsampleapp?viewId=Demo-DatePicker-View&methodToCall=start 038 */ 039 public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-DatePicker-View&methodToCall=start"; 040 041 @Override 042 protected String getBookmarkUrl() { 043 return BOOKMARK_URL; 044 } 045 046 @Override 047 protected void navigate() throws Exception { 048 waitAndClickById("Demo-LibraryLink", ""); 049 waitAndClickByLinkText("Widgets"); 050 waitAndClickByLinkText("DatePicker"); 051 } 052 053 protected void testWidgetsDatePickerDefault() throws Exception { 054 055 //click on datepicker 056 waitAndClick(By.cssSelector("img.ui-datepicker-trigger")); 057 058 //select today 059 waitAndClick(By.cssSelector(".ui-datepicker-current")); 060 061 //make sure today is populated 062 String today = new SimpleDateFormat("MM/dd/yyyy").format(new Date()); 063 String populatedDate = driver.findElement(By.id("u100085_control")).getAttribute("value"); 064 if (!populatedDate.equals(today)) { 065 fail("DatePicker did not populate correct value."); 066 } 067 068 } 069 070 protected void testWidgetsDatePickerWidget() throws Exception { 071 waitAndClickByLinkText(">> Open Library Navigation"); 072 waitAndClickByLinkText("Suggest"); 073 waitAndClickByLinkText("Tooltip"); 074 select(By.id("Demo-LargeExampleDropdown_control"), "Tooltip On Focus"); 075 076 //focus label 077 fireMouseOverEvent(By.id("u100101_label")); 078 Thread.sleep(1000); 079 WebElement tooltipFocusLabel = driver.findElement(By.xpath("//div[@data-for=\"u100101_label\"]")).findElement( 080 By.className("jquerybubblepopup-innerHtml")); 081 if (!tooltipFocusLabel.isDisplayed()) { 082 fail("Tooltip help for label not displayed."); 083 } 084 if (!tooltipFocusLabel.getText().equals("Click on the text box for a tool tip")) { 085 fail("Incorrect inner html text for label focus tooltip."); 086 } 087 088 //focus control 089 waitAndClickById("u100101_control"); 090 Thread.sleep(1000); 091 WebElement tooltipFocusControl = driver.findElement(By.xpath("//div[@data-for=\"u100101_control\"]")) 092 .findElement(By.className("jquerybubblepopup-innerHtml")); 093 if (!tooltipFocusControl.isDisplayed()) { 094 fail("Tooltip help for control not displayed."); 095 } 096 if (!tooltipFocusControl.getText().equals("This tooltip appears when the field receives focus")) { 097 fail("Incorrect inner html text for tooltip focus control."); 098 } 099 } 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 }