View Javadoc

1   package edu.samplu.krad.compview;
2   
3   
4   import edu.samplu.common.UpgradedSeleniumITBase;
5   import org.junit.Assert;
6   import org.junit.Test;
7   
8   /**
9    * @author Kuali Rice Team (rice.collab@kuali.org)
10   */
11  public class RichMessagesValidationIT extends UpgradedSeleniumITBase {
12  	
13  	@Override
14      public String getTestUrl() {
15          return "/kr-krad/uicomponents?viewId=RichMessagesView&methodToCall=start";
16      }
17  
18  	@Test
19  	public void testRichMessagesValidationIT() throws Exception {
20  		
21  		checkForIncidentReport(getTestUrl());
22          Thread.sleep(9000);
23          selectWindow("title=Kuali :: Rich Messages");
24  		
25  		//Verify Basic Functionality Section
26  		this.verifyBasicFunctionality();
27  				
28  		//Verify Advanced Functionality Section
29  		this.verifyAdvancedFunctionality();
30  				
31  		//Verify Letters and Numbers Validation
32  		this.verifyLettersNumbersValidation();
33  				
34  		//Verify Radio and Checkbox groups rich messages Section
35  		this.verifyRadioAndCheckBoxGroupFunctionality();
36  				
37  		//Verify Link Declarations Section
38  		this.verifyLinkDeclarationsFunctionality();
39  	}
40  	
41  	private void verifyBasicFunctionality() throws Exception
42  	{
43  		Assert.assertTrue(isElementPresent("//input[@type='text' and @name='field1']"));
44  		Assert.assertTrue(isElementPresent("//a[contains(text(), 'Kuali')]"));
45  		Assert.assertTrue(isElementPresent("//input[@type='checkbox' and @name='field2']"));
46  		Thread.sleep(3000);
47  	}
48  	
49  	private void verifyAdvancedFunctionality() throws Exception
50  	{
51  		//Color Options
52  		Assert.assertTrue(isElementPresent("//span[@style='color: green;']"));
53  		Assert.assertTrue(isElementPresent("//span[@style='color: blue;']"));
54  				
55  		//Css class
56  		Assert.assertTrue(isElementPresent("//span[@class='fl-text-underline fl-text-larger']"));
57  				
58  		//Combinations
59  		Assert.assertTrue(isElementPresent("//input[@type='text' and @name='field3']"));
60  		Assert.assertTrue(isElementPresent("//select[@name='field4']"));
61  		Assert.assertTrue(isElementPresent("//button[contains(text(), 'Action Button')]"));
62  		
63  		//Rich Message Field
64  		Assert.assertTrue(isElementPresent("//label[contains(., 'Label With')]/span[contains(., 'Color')]"));
65  		Assert.assertTrue(isElementPresent("//label[contains(., 'Label With')]/i/b[contains(., 'Html')]"));
66  		Assert.assertTrue(isElementPresent("//label[contains(., 'Label With')]/img[@class='uif-image inlineBlock']"));
67  		
68  		Thread.sleep(3000);
69  	}
70  
71  	private void verifyLettersNumbersValidation() throws Exception
72  	{
73  		//For letters only Validation
74  		Assert.assertTrue(isElementPresent("//input[@type='text' and @name='field5']"));
75  		focusAndType("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock']/input[@name= 'field5']","abc");
76  		Assert.assertFalse(isElementPresent("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
77  		focusAndType("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock']/input[@name= 'field5']","abc12");
78  		fireEvent("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock']/input[@name= 'field5']","blur");
79  		Thread.sleep(3000);
80  		Assert.assertTrue(isElementPresent("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
81  		focusAndType("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']/input[@name= 'field5']","abc");
82  		fireEvent("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']/input[@name= 'field5']","blur");
83  		
84  		//For numbers only validation
85  		focusAndType("//input[@name= 'field6']","123");
86  		Assert.assertFalse(isElementPresent("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
87  		focusAndType("//input[@name= 'field6']","123ab");
88  		fireEvent("//input[@name= 'field6']","blur");
89  		Thread.sleep(5000);
90  		Assert.assertTrue(isElementPresent("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
91  	
92  		Thread.sleep(3000);
93  	}
94  	
95  	private void verifyRadioAndCheckBoxGroupFunctionality() throws Exception
96  	{
97  		//Radio Group
98  		Assert.assertTrue(isElementPresent("//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='1']"));
99  		Assert.assertTrue(isElementPresent("//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='2']"));
100 		Assert.assertTrue(isElementPresent("//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='3']"));
101 		Assert.assertTrue(isElementPresent("//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='4']"));
102 		
103 		//Checkbox Group
104 		Assert.assertTrue(isElementPresent("//fieldset[@class='uif-verticalCheckboxesFieldset']/span/input[@type='checkbox' and @name='field115' and @value='1']"));
105 		Assert.assertTrue(isElementPresent("//fieldset[@class='uif-verticalCheckboxesFieldset']/span/input[@type='checkbox' and @name='field115' and @value='2']"));
106 		Assert.assertTrue(isElementPresent("//fieldset[@class='uif-verticalCheckboxesFieldset']/span/input[@type='checkbox' and @name='field115' and @value='3']"));
107 		Assert.assertTrue(isElementPresent("//fieldset[@class='uif-verticalCheckboxesFieldset']/span/label/div/select[@name='field4']"));
108 		
109 		//Checkbox Control
110 		Assert.assertTrue(isElementPresent("//input[@type='checkbox' and @name='bField1']"));
111 		Assert.assertTrue(isElementPresent("//input[@type='text' and @name='field103']"));
112 		
113 	}
114 	
115 	private void verifyLinkDeclarationsFunctionality() throws Exception
116 	{
117 		//Testing link tag
118 		waitAndClick("//div[contains(., 'Testing link tag')]/a");
119 		Thread.sleep(4000);
120 		selectWindow("title=Open Source Software | www.kuali.org");
121 		selectWindow("title=Kuali :: Rich Messages");
122 		
123 		//Testing methodToCall Action
124 	    waitAndClick("//div[contains(., 'Testing methodToCall action')]/a");
125 		Thread.sleep(3000);
126 		Assert.assertTrue(isElementPresent("//div[@class='fancybox-wrap fancybox-desktop fancybox-type-html fancybox-opened']"));
127 		Assert.assertTrue(isElementPresent("//div[@class='uif-validationMessages uif-groupValidationMessages uif-pageValidationMessages uif-pageValidationMessages-error']"));
128 		Assert.assertTrue(isElementPresent("//div[@id='Demo-AdvancedMessagesSection']/div[@class='uif-validationMessages uif-groupValidationMessages']"));
129 		Assert.assertTrue(isElementPresent("//div[@id='Demo-RadioCheckboxMessageSection']/div[@class='uif-validationMessages uif-groupValidationMessages']"));
130 		
131 		//Testing methodToCall action (no client validation check)
132 		waitAndClick("//div[contains(., 'Testing methodToCall action (no client validation check)')]/a");
133 		Assert.assertTrue(isElementPresent("//div[@class='uif-validationMessages uif-groupValidationMessages uif-pageValidationMessages uif-pageValidationMessages-error']"));
134 		Assert.assertTrue(isElementPresent("//div[@class='uif-validationMessages uif-groupValidationMessages']"));
135 		Assert.assertTrue(isElementPresent("//div[@class='uif-validationMessages uif-groupValidationMessages uif-pageValidationMessages uif-pageValidationMessages-error']"));
136 		Assert.assertTrue(isElementPresent("//div[@id='Demo-AdvancedMessagesSection']/div[@class='uif-validationMessages uif-groupValidationMessages']"));
137 		Assert.assertTrue(isElementPresent("//div[@id='Demo-RadioCheckboxMessageSection']/div[@class='uif-validationMessages uif-groupValidationMessages']"));
138 		Thread.sleep(3000);
139 	}
140 
141 }