1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.rice.krad.demo.uif.library.clientresponsiveness;
17  
18  import org.junit.Test;
19  
20  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21  import org.openqa.selenium.By;
22  import org.openqa.selenium.WebElement;
23  
24  
25  
26  
27  public class LibraryClientResponsivenessDisableAft extends WebDriverLegacyITBase {
28  
29      
30  
31  
32      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-DisableView&methodToCall=start";
33     
34      @Override
35      protected String getBookmarkUrl() {
36          return BOOKMARK_URL;
37      }
38  
39      @Override
40      protected void navigate() throws Exception {
41          waitAndClickLibraryLink();
42          waitAndClickByLinkText("Client Responsiveness");
43          waitAndClickByLinkText("Disable");
44      }
45  
46      protected void testClientResponsivenessDisable() throws Exception {
47         
48         waitAndClickByXpath("//input[@type='radio' and @value='enable']");
49         waitAndTypeByName("inputField2","a1");
50         waitAndTypeByName("inputField3","b");
51         selectByName("inputField4", "Option 2");
52         selectByName("multiSelectField1","Option 3");
53         waitAndClickByXpath("//input[@type='radio' and @value='1']");
54         waitAndClickByName("checkboxesField1");
55         waitForElementPresentByXpath("//a[@class='btn btn-default icon-calendar ui-datepicker-trigger']");
56         
57         
58         waitAndClickByXpath("//input[@type='radio' and @value='disable']");
59         if(isEnabledByName("inputField2") && isEnabledByName("inputField3") && isEnabledByName("inputField4") && isEnabledByName("inputField6") &&
60                 isEnabledByName("inputField7") && isEnabledByName("multiSelectField1")) {
61             fail("Field Not Disabled Properly.");
62         }
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73      }
74      
75      protected void testClientResponsivenessDisableOnChange() throws Exception {
76          selectByName("exampleShown","On change");
77          
78          
79          assertElementPresentByXpath("//button[@class='btn btn-primary uif-action uif-boxLayoutHorizontalItem disabled']");
80          waitAndTypeByName("inputField10","a");
81          waitAndTypeByName("inputField11","a");
82          waitAndTypeByName("inputField10", "");
83          assertElementPresentByXpath("//button[@class='btn btn-primary uif-action uif-boxLayoutHorizontalItem disabled']");
84        }
85      
86      protected void testClientResponsivenessDisableOnKeyUp() throws Exception {
87          selectByName("exampleShown","On keyup");
88          waitAndTypeByName("inputField13","disable");
89          assertElementPresentByXpath("//button[contains(text(),'Action Button (keyUp)') and @class='btn btn-primary uif-action uif-boxLayoutHorizontalItem disabled']");
90          fireEvent("inputField13", "blur");
91          typeTab();
92          assertElementPresentByXpath("//button[contains(text(),'Action Button (change)') and @class='btn btn-primary uif-action uif-boxLayoutHorizontalItem disabled']");
93       }
94      
95      protected void testClientResponsivenessDisableInCollections() throws Exception {
96          selectByName("exampleShown","In Collections");
97          WebElement element = findElement(By.name("newCollectionLines['collection1'].field3"));
98          assertTrue(element.getAttribute("class").contains("ignoreValid"));
99          selectByName("newCollectionLines['collection1'].field2","Disable");
100         Thread.sleep(1000);
101         assertElementPresentByXpath("//input[@disabled]");
102      }
103     
104     protected void testClientResponsivenessDisableColl() throws Exception {
105         selectByName("exampleShown","Coll. SpringEL Functions");
106         waitAndClickByXpath("//input[@name='checkboxesField2' and @value='1']");
107         WebElement element = findElement(By.name("inputField20"));
108         assertTrue(element.getAttribute("class").contains("disabled"));
109         waitAndClickByXpath("//input[@name='checkboxesField2' and @value='2']");
110         waitAndClickByXpath("//input[@name='checkboxesField2' and @value='3']");
111         element = findElement(By.name("inputField21"));
112         assertTrue(element.getAttribute("class").contains("disabled"));
113      }
114     
115     @Test
116     public void testClientResponsivenessDisableBookmark() throws Exception {
117         testClientResponsivenessDisable();
118         testClientResponsivenessDisableOnChange();
119         testClientResponsivenessDisableOnKeyUp();
120         testClientResponsivenessDisableInCollections();
121         testClientResponsivenessDisableColl();
122         passed();
123     }
124 
125     @Test
126     public void testClientResponsivenessDisableNav() throws Exception {
127         testClientResponsivenessDisable();
128         testClientResponsivenessDisableOnChange();
129         testClientResponsivenessDisableInCollections();
130         testClientResponsivenessDisableColl();
131         testClientResponsivenessDisableOnKeyUp();
132         passed();
133     }  
134 }