001    package edu.samplu.krad.compview;
002    
003    
004    import edu.samplu.common.UpgradedSeleniumITBase;
005    import org.junit.Assert;
006    import org.junit.Test;
007    
008    /**
009     * @author Kuali Rice Team (rice.collab@kuali.org)
010     */
011    public class RichMessagesValidationIT extends UpgradedSeleniumITBase {
012            
013            @Override
014        public String getTestUrl() {
015            return "/kr-krad/uicomponents?viewId=RichMessagesView&methodToCall=start";
016        }
017    
018            @Test
019            public void testRichMessagesValidationIT() throws Exception {
020                    
021                    checkForIncidentReport(getTestUrl());
022            Thread.sleep(9000);
023            selectWindow("title=Kuali :: Rich Messages");
024                    
025                    //Verify Basic Functionality Section
026                    this.verifyBasicFunctionality();
027                                    
028                    //Verify Advanced Functionality Section
029                    this.verifyAdvancedFunctionality();
030                                    
031                    //Verify Letters and Numbers Validation
032                    this.verifyLettersNumbersValidation();
033                                    
034                    //Verify Radio and Checkbox groups rich messages Section
035                    this.verifyRadioAndCheckBoxGroupFunctionality();
036                                    
037                    //Verify Link Declarations Section
038                    this.verifyLinkDeclarationsFunctionality();
039            }
040            
041            private void verifyBasicFunctionality() throws Exception
042            {
043                    Assert.assertTrue(isElementPresent("//input[@type='text' and @name='field1']"));
044                    Assert.assertTrue(isElementPresent("//a[contains(text(), 'Kuali')]"));
045                    Assert.assertTrue(isElementPresent("//input[@type='checkbox' and @name='field2']"));
046                    Thread.sleep(3000);
047            }
048            
049            private void verifyAdvancedFunctionality() throws Exception
050            {
051                    //Color Options
052                    Assert.assertTrue(isElementPresent("//span[@style='color: green;']"));
053                    Assert.assertTrue(isElementPresent("//span[@style='color: blue;']"));
054                                    
055                    //Css class
056                    Assert.assertTrue(isElementPresent("//span[@class='fl-text-underline fl-text-larger']"));
057                                    
058                    //Combinations
059                    Assert.assertTrue(isElementPresent("//input[@type='text' and @name='field3']"));
060                    Assert.assertTrue(isElementPresent("//select[@name='field4']"));
061                    Assert.assertTrue(isElementPresent("//button[contains(text(), 'Action Button')]"));
062                    
063                    //Rich Message Field
064                    Assert.assertTrue(isElementPresent("//label[contains(., 'Label With')]/span[contains(., 'Color')]"));
065                    Assert.assertTrue(isElementPresent("//label[contains(., 'Label With')]/i/b[contains(., 'Html')]"));
066                    Assert.assertTrue(isElementPresent("//label[contains(., 'Label With')]/img[@class='uif-image inlineBlock']"));
067                    
068                    Thread.sleep(3000);
069            }
070    
071            private void verifyLettersNumbersValidation() throws Exception
072            {
073                    //For letters only Validation
074                    Assert.assertTrue(isElementPresent("//input[@type='text' and @name='field5']"));
075                    focusAndType("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock']/input[@name= 'field5']","abc");
076                    Assert.assertFalse(isElementPresent("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
077                    focusAndType("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock']/input[@name= 'field5']","abc12");
078                    fireEvent("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock']/input[@name= 'field5']","blur");
079                    Thread.sleep(3000);
080                    Assert.assertTrue(isElementPresent("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
081                    focusAndType("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']/input[@name= 'field5']","abc");
082                    fireEvent("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']/input[@name= 'field5']","blur");
083                    
084                    //For numbers only validation
085                    focusAndType("//input[@name= 'field6']","123");
086                    Assert.assertFalse(isElementPresent("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
087                    focusAndType("//input[@name= 'field6']","123ab");
088                    fireEvent("//input[@name= 'field6']","blur");
089                    Thread.sleep(5000);
090                    Assert.assertTrue(isElementPresent("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
091            
092                    Thread.sleep(3000);
093            }
094            
095            private void verifyRadioAndCheckBoxGroupFunctionality() throws Exception
096            {
097                    //Radio Group
098                    Assert.assertTrue(isElementPresent("//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='1']"));
099                    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    }