001    package edu.samplu.krad.compview;
002    
003    
004    import edu.samplu.common.WebDriverLegacyITBase;
005    
006    import org.junit.Assert;
007    import org.junit.Test;
008    
009    /**
010     * @author Kuali Rice Team (rice.collab@kuali.org)
011     */
012    public class RichMessagesValidationLegacyIT extends WebDriverLegacyITBase {
013            
014            @Override
015        public String getTestUrl() {
016            return "/kr-krad/uicomponents?viewId=RichMessagesView&methodToCall=start";
017        }
018    
019            @Test
020            public void testRichMessagesValidationIT() throws Exception {
021                    
022                    checkForIncidentReport(getTestUrl());
023            Thread.sleep(9000);
024    //        selectWindow("Kuali :: Rich Messages");
025                    
026                    //Verify Basic Functionality Section
027                    this.verifyBasicFunctionality();
028                                    
029                    //Verify Advanced Functionality Section
030                    this.verifyAdvancedFunctionality();
031                                    
032                    //Verify Letters and Numbers Validation
033                    this.verifyLettersNumbersValidation();
034                                    
035                    //Verify Radio and Checkbox groups rich messages Section
036                    this.verifyRadioAndCheckBoxGroupFunctionality();
037                                    
038                    //Verify Link Declarations Section
039                    this.verifyLinkDeclarationsFunctionality();
040            passed();
041            }
042            
043            private void verifyBasicFunctionality() throws Exception
044            {
045                    Assert.assertTrue(isElementPresentByXpath("//input[@type='text' and @name='field1']"));
046                    Assert.assertTrue(isElementPresentByXpath("//a[contains(text(), 'Kuali')]"));
047                    Assert.assertTrue(isElementPresentByXpath("//input[@type='checkbox' and @name='field2']"));
048                    Thread.sleep(3000);
049            }
050            
051            private void verifyAdvancedFunctionality() throws Exception
052            {
053                    //Color Options
054                    Assert.assertTrue(isElementPresentByXpath("//span[@style='color: green;']"));
055                    Assert.assertTrue(isElementPresentByXpath("//span[@style='color: blue;']"));
056                                    
057                    //Css class
058                    Assert.assertTrue(isElementPresentByXpath("//span[@class='fl-text-underline fl-text-larger']"));
059                                    
060                    //Combinations
061                    Assert.assertTrue(isElementPresentByXpath("//input[@type='text' and @name='field3']"));
062                    Assert.assertTrue(isElementPresentByXpath("//select[@name='field4']"));
063                    Assert.assertTrue(isElementPresentByXpath("//button[contains(text(), 'Action Button')]"));
064                    
065                    //Rich Message Field
066                    Assert.assertTrue(isElementPresentByXpath("//label[contains(., 'Label With')]/span[contains(., 'Color')]"));
067                    Assert.assertTrue(isElementPresentByXpath("//label[contains(., 'Label With')]/i/b[contains(., 'Html')]"));
068                    Assert.assertTrue(isElementPresentByXpath("//label[contains(., 'Label With')]/img[@class='uif-image inlineBlock']"));
069                    
070                    Thread.sleep(3000);
071            }
072    
073            private void verifyLettersNumbersValidation() throws Exception
074            {
075                    //For letters only Validation
076                    Assert.assertTrue(isElementPresentByXpath("//input[@type='text' and @name='field5']"));
077                    waitAndTypeByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock']/input[@name= 'field5']","abc");
078                    Assert.assertFalse(isElementPresentByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
079                    clearTextByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock']/input[@name= 'field5']");
080                    waitAndTypeByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock']/input[@name= 'field5']","abc12");
081    
082                    waitAndTypeByXpath("//input[@name= 'field6']","");
083                    Assert.assertTrue(isElementPresentByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
084                    Thread.sleep(3000);
085                    clearTextByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']/input[@name= 'field5']");
086                    waitAndTypeByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']/input[@name= 'field5']","abc");
087                    waitAndTypeByXpath("//input[@name= 'field6']","");
088                    
089                    
090                    //For numbers only validation
091                    waitAndTypeByXpath("//input[@name= 'field6']","123");
092                    Assert.assertFalse(isElementPresentByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
093                    clearTextByXpath("//input[@name= 'field6']");
094                    waitAndTypeByXpath("//input[@name= 'field6']","123ab");
095                    fireEvent("field6","blur");
096                    Thread.sleep(5000);
097                    Assert.assertTrue(isElementPresentByXpath("//div[@class='uif-field uif-inputField uif-inputField-labelTop inlineBlock uif-hasError']"));
098            
099                    Thread.sleep(3000);
100            }
101            
102            private void verifyRadioAndCheckBoxGroupFunctionality() throws Exception
103            {
104                    //Radio Group
105                    Assert.assertTrue(isElementPresentByXpath("//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='1']"));
106                    Assert.assertTrue(isElementPresentByXpath("//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='2']"));
107                    Assert.assertTrue(isElementPresentByXpath("//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='3']"));
108                    Assert.assertTrue(isElementPresentByXpath("//fieldset[@class='uif-verticalRadioFieldset']/span/input[@type='radio' and @name='field24' and @value='4']"));
109                    
110                    //Checkbox Group
111                    Assert.assertTrue(isElementPresentByXpath("//fieldset[@class='uif-verticalCheckboxesFieldset']/span/input[@type='checkbox' and @name='field115' and @value='1']"));
112                    Assert.assertTrue(isElementPresentByXpath("//fieldset[@class='uif-verticalCheckboxesFieldset']/span/input[@type='checkbox' and @name='field115' and @value='2']"));
113                    Assert.assertTrue(isElementPresentByXpath("//fieldset[@class='uif-verticalCheckboxesFieldset']/span/input[@type='checkbox' and @name='field115' and @value='3']"));
114                    Assert.assertTrue(isElementPresentByXpath("//fieldset[@class='uif-verticalCheckboxesFieldset']/span/label/div/select[@name='field4']"));
115                    
116                    //Checkbox Control
117                    Assert.assertTrue(isElementPresentByXpath("//input[@type='checkbox' and @name='bField1']"));
118                    Assert.assertTrue(isElementPresentByXpath("//input[@type='text' and @name='field103']"));
119                    
120            }
121            
122            private void verifyLinkDeclarationsFunctionality() throws Exception
123            {
124                    //Testing link tag
125                    waitAndClickByXpath("//div[contains(., 'Testing link tag')]/a");
126                    Thread.sleep(9000);
127                    switchToWindow("Open Source Software | www.kuali.org");
128                    switchToWindow("Kuali :: Rich Messages");
129                    
130                    //Testing methodToCall Action
131                waitAndClickByXpath("//div[contains(., 'Testing methodToCall action')]/a");
132                    Thread.sleep(3000);
133                    Assert.assertTrue(isElementPresentByXpath("//div[@class='fancybox-wrap fancybox-desktop fancybox-type-html fancybox-opened']"));
134                    Assert.assertTrue(isElementPresentByXpath("//div[@class='uif-validationMessages uif-groupValidationMessages uif-pageValidationMessages uif-pageValidationMessages-error']"));
135                    Assert.assertTrue(isElementPresentByXpath("//div[@id='Demo-AdvancedMessagesSection']/div[@class='uif-validationMessages uif-groupValidationMessages']"));
136                    Assert.assertTrue(isElementPresentByXpath("//div[@id='Demo-RadioCheckboxMessageSection']/div[@class='uif-validationMessages uif-groupValidationMessages']"));
137                    
138                    //Testing methodToCall action (no client validation check)
139                    waitAndClickByXpath("//div[contains(., 'Testing methodToCall action (no client validation check)')]/a");
140                    Assert.assertTrue(isElementPresentByXpath("//div[@class='uif-validationMessages uif-groupValidationMessages uif-pageValidationMessages uif-pageValidationMessages-error']"));
141                    Assert.assertTrue(isElementPresentByXpath("//div[@class='uif-validationMessages uif-groupValidationMessages']"));
142                    Assert.assertTrue(isElementPresentByXpath("//div[@class='uif-validationMessages uif-groupValidationMessages uif-pageValidationMessages uif-pageValidationMessages-error']"));
143                    Assert.assertTrue(isElementPresentByXpath("//div[@id='Demo-AdvancedMessagesSection']/div[@class='uif-validationMessages uif-groupValidationMessages']"));
144                    Assert.assertTrue(isElementPresentByXpath("//div[@id='Demo-RadioCheckboxMessageSection']/div[@class='uif-validationMessages uif-groupValidationMessages']"));
145                    Thread.sleep(3000);
146            }
147    
148    }