1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
27
28 public class DemoLibraryWidgetsDatePickerSmokeTest extends DemoLibraryBase {
29
30
31
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
49 waitAndClick(By.cssSelector("img.ui-datepicker-trigger"));
50
51
52 waitAndClick(By.cssSelector(".ui-datepicker-current"));
53
54
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
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
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 }