1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  package edu.samplu.travel.krad.test;
18  
19  import edu.samplu.common.UpgradedSeleniumITBase;
20  import org.junit.Assert;
21  import org.junit.Ignore;
22  import org.junit.Test;
23  
24  import static junit.framework.Assert.*;
25  
26  
27  
28  
29  
30  
31  public class ConfigurationTestViewIT extends UpgradedSeleniumITBase {
32      @Override
33      public String getTestUrl() {
34          return PORTAL;
35      }
36      
37      private String idPrefix = "ConfigurationTestView-ProgressiveRender-";
38      
39      String addLineIdSuffix = "InputField_add_control";
40  
41  	@Test
42      
43  
44  
45  	public void testConfigurationTestView() throws Exception {
46          openConfigurationTestView();
47  
48          
49          String styleValue = selenium.getAttribute("//span[@id='" + idPrefix + "TextInputField_label_span']@style");
50          
51          Assert.assertTrue(idPrefix + "textInputField label does not contain expected style", styleValue.replace(" ", "").contains(
52                  "color:red"));
53  
54          
55          selenium.selectFrame("iframeportlet");
56          
57          String refreshTextSelectLocator = "id=" + idPrefix + "RefreshTextField_control";
58          String[] options1 = selenium.getSelectOptions(refreshTextSelectLocator);
59          String dropDownSelectLocator = "id=" + idPrefix + "DropDown_control";
60          selenium.select(dropDownSelectLocator, "label=Vegetables");
61          selenium.click("//option[@value='Vegetables']");
62          Thread.sleep(3000);
63          
64          String[] options2 = selenium.getSelectOptions(refreshTextSelectLocator);
65          
66          assertFalse(options1[options1.length - 1].equalsIgnoreCase(options2[options2.length - 1]));
67          
68          selenium.select(dropDownSelectLocator, "label=None");
69          Thread.sleep(3000);
70          assertEquals("true", selenium.getAttribute(refreshTextSelectLocator+ "@disabled"));
71  
72  	}
73  
74      
75  
76  
77      private void openConfigurationTestView() {
78          selenium.click("link=KRAD");
79          selenium.waitForPageToLoad("30000");
80          selenium.isElementPresent("link=Configuration Test View");
81          selenium.click("link=Configuration Test View");
82          selenium.waitForPageToLoad("30000");
83      }
84  
85      
86  
87  
88  
89      @Test
90      public void testAddLineWithSpecificTime() throws Exception{
91          openConfigurationTestView();
92          confirmAddLineControlsPresent();
93  
94          String startTimeId = "id=" +idPrefix + "StartTime" + addLineIdSuffix;
95          selenium.focus(startTimeId);
96          String inputTime = "7:06";
97          selenium.type(startTimeId, inputTime);
98  
99          String amPmSelectLocator = "id=" + idPrefix + "StartTimeAmPm" + addLineIdSuffix;
100         selenium.click(amPmSelectLocator);
101         selenium.select(amPmSelectLocator, "label=PM");
102         assertEquals("PM", selenium.getSelectedLabel(amPmSelectLocator));
103 
104         Thread.sleep(5000); 
105         selenium.click("css=div#ConfigurationTestView-ProgressiveRender-TimeInfoSection button");
106         Thread.sleep(5000); 
107 
108         
109         assertTrue("line is not present", selenium.isElementPresent("//input[@value='7:06']"));
110     }
111 
112     
113 
114 
115 
116         @Test
117         public void testAddLineWithAllDay() throws Exception{
118             openConfigurationTestView();
119             confirmAddLineControlsPresent();
120 
121             String startTimeId = "id=" +idPrefix + "StartTime" + addLineIdSuffix;
122             selenium.focus(startTimeId);
123             String inputTime = "5:20";
124             selenium.type(startTimeId, inputTime);
125 
126             String allDaySelector = "id=" + idPrefix + "AllDay" + addLineIdSuffix;
127             selenium.focus(allDaySelector);
128             Thread.sleep(5000); 
129             selenium.click(allDaySelector);
130 
131             String amPmSelectLocator = "id=" + idPrefix + "StartTimeAmPm" + addLineIdSuffix;
132             selenium.click(amPmSelectLocator);
133             selenium.select(amPmSelectLocator, "label=PM");
134             assertEquals("PM", selenium.getSelectedLabel(amPmSelectLocator));
135 
136             Thread.sleep(5000); 
137             selenium.click("css=div#ConfigurationTestView-ProgressiveRender-TimeInfoSection button");
138             Thread.sleep(5000); 
139 
140             
141             assertTrue("line is not present", selenium.isElementPresent("//input[@value='5:20']"));
142         }
143 
144     
145 
146 
147     private void confirmAddLineControlsPresent() {
148         String[] addLineIds = {"StartTime", "StartTimeAmPm", "AllDay"};
149 
150         for (String id: addLineIds) {
151             String tagId = "id=" + idPrefix + id + addLineIdSuffix;
152            assertTrue("Did not find id " + tagId, selenium.isElementPresent(tagId));
153         }
154     }
155 
156     
157 
158 
159 
160     @Test
161     @Ignore("count rows through CSS or XPATH fails")
162     public void testAddLineAllDay() throws Exception{
163         openConfigurationTestView();
164         confirmAddLineControlsPresent();
165 
166         
167         String cssCountRows = "div#ConfigurationTestView-ProgressiveRender-TimeInfoSection.uif-group div#ConfigurationTestView-ProgressiveRender-TimeInfoSection_disclosureContent.uif-disclosureContent table tbody tr";
168         int rowCount = (selenium.getCssCount(cssCountRows)).intValue();
169 
170         String allDayId = "id=" + idPrefix + "AllDay" + addLineIdSuffix;
171         selenium.focus(allDayId);
172         Thread.sleep(5000); 
173         selenium.click(allDayId);
174         selenium.click("css=div#ConfigurationTestView-ProgressiveRender-TimeInfoSection button");
175         Thread.sleep(5000); 
176 
177         
178         assertEquals("line was not added", rowCount + 1, (selenium.getCssCount(cssCountRows)).intValue());
179     }
180 }