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 passed();
63 }
64
65 protected void testConfigurationTestViewBookmark(JiraAwareFailable failable) throws Exception {
66 testConfigurationTestView(idPrefix);
67 testAddLineWithSpecificTime(idPrefix, addLineIdSuffix);
68 testAddLineWithAllDay(idPrefix, addLineIdSuffix);
69 testAddLineAllDay(idPrefix, addLineIdSuffix);
70 passed();
71 }
72
73 protected void testAddLineWithSpecificTime(String idPrefix, String addLineIdSuffix) throws Exception {
74 waitForElementPresentByXpath("//label[@id='" + idPrefix + "TextInputField_label']");
75 confirmAddLineControlsPresent(idPrefix, addLineIdSuffix);
76 String startTimeId = "//*[@id='" + idPrefix + "StartTime" + addLineIdSuffix + "']";
77 String inputTime = "7:06";
78 waitAndTypeByXpath(startTimeId, inputTime);
79 String amPmSelectLocator = "//*[@id='" + idPrefix + "StartTimeAmPm" + addLineIdSuffix + "']";
80 selectByXpath(amPmSelectLocator, "PM");
81 assertEquals("PM", waitAndGetAttributeByXpath(amPmSelectLocator, "value"));
82 Thread.sleep(5000);
83 waitAndClickButtonByText("Add");
84 Thread.sleep(5000);
85
86
87 assertTrue("line (//input[@value='7:06'])is not present", isElementPresentByXpath("//input[@value='7:06']"));
88 }
89
90 protected void testAddLineWithAllDay(String idPrefix, String addLineIdSuffix) throws Exception {
91 waitForElementPresentByXpath("//label[@id='" + idPrefix + "TextInputField_label']");
92 confirmAddLineControlsPresent(idPrefix, addLineIdSuffix);
93 String startTimeId = "//*[@id='" + idPrefix + "StartTime" + addLineIdSuffix + "']";
94 String inputTime = "5:20";
95 waitAndTypeByXpath(startTimeId, inputTime);
96 String allDayId = "//*[@id='" + idPrefix + "AllDay" + addLineIdSuffix + "']";
97 waitAndClickByXpath(allDayId);
98 checkForIncidentReport();
99 Thread.sleep(5000);
100 waitAndClickButtonByText("Add");
101 Thread.sleep(5000);
102
103
104 assertTrue("line (//input[@checked='checked'])is not present", isElementPresentByXpath("//input[@checked='checked']"));
105 }
106
107 protected void testAddLineAllDay(String idPrefix, String addLineIdSuffix) throws Exception {
108 waitForElementPresentByXpath("//label[@id='" + idPrefix + "TextInputField_label']");
109 confirmAddLineControlsPresent(idPrefix, addLineIdSuffix);
110 String allDayId = "//*[@id='" + idPrefix + "AllDay" + addLineIdSuffix + "']";
111 waitAndClickByXpath(allDayId);
112 checkForIncidentReport();
113 Thread.sleep(5000);
114 waitAndClickButtonByText("Add");
115 Thread.sleep(5000);
116
117
118 WebElement table = findElement(By.id("ConfigurationTestView-ProgressiveRender-TimeInfoSection_disclosureContent"));
119 List<WebElement> columns = findElements(By.xpath("//button[contains(text(), 'Delete')]"), table);
120 assertEquals("line was not added", 3, columns.size());
121
122 }
123
124
125
126
127 protected void confirmAddLineControlsPresent(String idPrefix, String addLineIdSuffix) {
128 String[] addLineIds = {"StartTime", "StartTimeAmPm", "AllDay"};
129
130 for (String id : addLineIds) {
131 String tagId = "//*[@id='" + idPrefix + id + addLineIdSuffix + "']";
132 assertTrue("Did not find id " + tagId, isElementPresentByXpath(tagId));
133 }
134 }
135
136 }