1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.krad.configview;
17
18 import org.kuali.rice.testtools.common.JiraAwareFailable;
19 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
20 import org.openqa.selenium.By;
21 import org.openqa.selenium.WebElement;
22
23 import java.util.List;
24
25
26
27
28
29
30 public abstract class ConfigurationTestViewAftBase extends WebDriverLegacyITBase {
31
32
33
34
35 public static final String BOOKMARK_URL = "/kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView&methodToCall=start";
36
37
38 private String idPrefix = "ConfigurationTestView-ProgressiveRender-";
39
40
41 String addLineIdSuffix = "InputField_add_control";
42
43
44 @Override
45 protected String getBookmarkUrl() {
46 return BOOKMARK_URL;
47 }
48
49 protected void navigation() throws InterruptedException {
50 waitAndClickKRAD();
51 waitAndClickByXpath("(//a[text()='Configuration Test View'])");
52 switchToWindow(CONFIGURATION_VIEW_WINDOW_TITLE);
53 waitForTitleToEqualKualiPortalIndex();
54 }
55
56 protected void testConfigurationTestViewNav(JiraAwareFailable failable) throws Exception {
57 navigation();
58 testConfigurationTestView(idPrefix);
59 testAddLineWithSpecificTime(idPrefix, addLineIdSuffix);
60 testAddLineWithAllDay(idPrefix, addLineIdSuffix);
61 testAddLineAllDay(idPrefix, addLineIdSuffix);
62 testInitialColumnSorting(idPrefix);
63 passed();
64 }
65
66 protected void testConfigurationTestViewBookmark(JiraAwareFailable failable) throws Exception {
67 testConfigurationTestView(idPrefix);
68 testAddLineWithSpecificTime(idPrefix, addLineIdSuffix);
69 testAddLineWithAllDay(idPrefix, addLineIdSuffix);
70 testAddLineAllDay(idPrefix, addLineIdSuffix);
71 testInitialColumnSorting(idPrefix);
72 passed();
73 }
74
75 protected void testAddLineWithSpecificTime(String idPrefix, String addLineIdSuffix) throws Exception {
76 waitForElementPresentByXpath("//label[@id='" + idPrefix + "TextInputField_label']");
77 confirmAddLineControlsPresent(idPrefix, addLineIdSuffix);
78 String startTimeId = "//*[@id='" + idPrefix + "StartTime" + addLineIdSuffix + "']";
79 String inputTime = "7:06";
80 waitAndTypeByXpath(startTimeId, inputTime);
81 String amPmSelectLocator = "//*[@id='" + idPrefix + "StartTimeAmPm" + addLineIdSuffix + "']";
82 selectByXpath(amPmSelectLocator, "PM");
83 assertEquals("PM", waitAndGetAttributeByXpath(amPmSelectLocator, "value"));
84 Thread.sleep(5000);
85 waitAndClickButtonByText("Add");
86 Thread.sleep(5000);
87
88
89 assertTrue("line (//input[@value='7:06'])is not present", isElementPresentByXpath("//input[@value='7:06']"));
90 }
91
92 protected void testAddLineWithAllDay(String idPrefix, String addLineIdSuffix) throws Exception {
93 waitForElementPresentByXpath("//label[@id='" + idPrefix + "TextInputField_label']");
94 confirmAddLineControlsPresent(idPrefix, addLineIdSuffix);
95 String startTimeId = "//*[@id='" + idPrefix + "StartTime" + addLineIdSuffix + "']";
96 String inputTime = "5:20";
97 waitAndTypeByXpath(startTimeId, inputTime);
98 String allDayId = "//*[@id='" + idPrefix + "AllDay" + addLineIdSuffix + "']";
99 waitAndClickByXpath(allDayId);
100 checkForIncidentReport();
101 Thread.sleep(5000);
102 waitAndClickButtonByText("Add");
103 Thread.sleep(5000);
104
105
106 assertTrue("line (//input[@checked='checked'])is not present", isElementPresentByXpath("//input[@checked='checked']"));
107 }
108
109 protected void testAddLineAllDay(String idPrefix, String addLineIdSuffix) throws Exception {
110 waitForElementPresentByXpath("//label[@id='" + idPrefix + "TextInputField_label']");
111 confirmAddLineControlsPresent(idPrefix, addLineIdSuffix);
112 String allDayId = "//*[@id='" + idPrefix + "AllDay" + addLineIdSuffix + "']";
113 waitAndClickByXpath(allDayId);
114 checkForIncidentReport();
115 Thread.sleep(5000);
116 waitAndClickButtonByText("Add");
117 Thread.sleep(5000);
118
119
120 WebElement table = findElement(By.id("ConfigurationTestView-ProgressiveRender-TimeInfoSection_disclosureContent"));
121 List<WebElement> columns = findElements(By.xpath("//button[contains(text(), 'Delete')]"), table);
122 assertEquals("line was not added", 3, columns.size());
123
124 }
125
126 protected void testInitialColumnSorting(String idPrefix) throws Exception {
127 waitForElementPresentByXpath("//section[@id = '" + idPrefix + "DayEventSection']");
128
129
130 waitForElementPresentByXpath("//section[@id = '" + idPrefix + "DayEventSection']//table/tbody/tr[1]/td[2]//span[contains(text(), '10/01/2010')]");
131 waitForElementPresentByXpath("//section[@id = '" + idPrefix + "DayEventSection']//table/tbody/tr[2]/td[2]//span[contains(text(), '10/02/2010')]");
132 waitForElementPresentByXpath("//section[@id = '" + idPrefix + "DayEventSection']//table/tbody/tr[3]/td[2]//span[contains(text(), '10/03/2010')]");
133 waitForElementPresentByXpath("//section[@id = '" + idPrefix + "DayEventSection']//table/tbody/tr[4]/td[2]//span[contains(text(), '10/04/2010')]");
134 waitForElementPresentByXpath("//section[@id = '" + idPrefix + "DayEventSection']//table/tbody/tr[5]/td[2]//span[contains(text(), '10/05/2010')]");
135 }
136
137
138
139
140 protected void confirmAddLineControlsPresent(String idPrefix, String addLineIdSuffix) {
141 String[] addLineIds = {"StartTime", "StartTimeAmPm", "AllDay"};
142
143 for (String id : addLineIds) {
144 String tagId = "//*[@id='" + idPrefix + id + addLineIdSuffix + "']";
145 assertTrue("Did not find id " + tagId, isElementPresentByXpath(tagId));
146 }
147 }
148
149 }