001 /**
002 * Copyright 2005-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package edu.sampleu.krad.validationmessagesview;
017
018 import org.junit.Test;
019 import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
020
021 /**
022 * Tests the Component section in Rice.
023 *
024 * @author Kuali Rice Team (rice.collab@kuali.org)
025 */
026 public class ServerSideTestViewAft extends WebDriverLegacyITBase {
027
028 /**
029 * "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&readOnlyFields=field91";
030 */
031 public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=Demo-ValidationServerSide&methodToCall=start";
032
033 private static final String ERROR_ELEMENT_XPATH="//div[@class='uif-inputField uif-boxLayoutVerticalItem clearfix uif-hasError']";
034
035 @Override
036 protected String getBookmarkUrl() {
037 return BOOKMARK_URL;
038 }
039
040 protected void navigate() throws InterruptedException {
041 waitAndClickKRAD();
042 waitAndClickByLinkText("ServerSide Constraint Validation Demo");
043 switchToWindow("Kuali :: Validation Server-side Test View");
044 }
045
046 //Code for KRAD Test Package.
047 protected void testServerSideTestView() throws Exception {
048
049 //MinMax length and value and Required Constraint
050 waitAndTypeByName("field9","a");
051 waitAndTypeByName("field10","1");
052 waitAndClickByXpath("//button[@id='usave']");
053 waitForTextPresent("MinMax Length test: Must be between 2 and 5 characters long");
054 assertTextPresent("MinMax Value test: Value must be greater than 2 and no more than 50");
055 assertTextPresent(new String[]{"Required constraint", "4 errors"});
056 assertElementPresentByXpath("//div[@class='uif-inputField uif-boxLayoutHorizontalItem uif-hasError']");
057 fireMouseOverEventByName("field3");
058 waitForTextPresent("Field Label is a required field.");
059 fireMouseOverEventByName("field4");
060 waitForTextPresent("Radio is a required field.");
061 fireMouseOverEventByName("field5");
062 waitForTextPresent("Select is a required field.");
063
064 //PreRequisite constraint
065 // waitForElementPresentByXpath("//input[@name='field7' and @disabled]");
066 // waitAndClickByXpath("//input[@type='checkbox' and @name='booleanField']");
067 // if(isElementPresentByXpath("//input[@name='field7' and @disabled]")) {
068 // fail("PreRequisite Constraint isn't working !");
069 // }
070
071 //MustOccurs constraint
072 waitAndTypeByName("field14","a");
073 waitAndClickByXpath("//button[@id='usave']");
074 Thread.sleep(4000);
075
076 //Case constraint
077 waitAndClickByXpath("//input[@name='field24' and @value='case1']");
078 waitAndClickByXpath("//button[@id='usave']");
079 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field25']");
080 waitAndClickByXpath("//input[@name='field24' and @value='case2']");
081 waitAndClickByXpath("//button[@id='usave']");
082 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field25']");
083 waitAndTypeByName("field25","123@#");
084 waitAndClickByXpath("//button[@id='usave']");
085 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field25']");
086 fireMouseOverEventByName("field25");
087 waitForTextPresent(" Can only be alphanumeric characters");
088 waitAndTypeByName("field26","1234");
089 waitAndClickByXpath("//input[@name='field24' and @value='case3']");
090 waitAndClickByXpath("//button[@id='usave']");
091 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field26']");
092 fireMouseOverEventByName("field26");
093 waitForTextPresent(" Value cannot be greater than 500");
094 waitForTextPresent(" Must be at most 3 characters");
095 waitAndTypeByName("field31","as");
096 waitAndTypeByName("field32","asd");
097 waitAndClickByXpath("//button[@id='usave']");
098 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field33']");
099
100 //All remaining constraint
101 waitAndTypeByName("field50","1111.111");
102 waitAndTypeByName("field51","#1L");
103 waitAndTypeByName("field77","1.1");
104 waitAndTypeByName("field52","asdfasdf");
105 waitAndTypeByName("field53","deep");
106 waitAndTypeByName("field54","aad.@c");
107 waitAndTypeByName("field84","www.kuali.org");
108 waitAndTypeByName("field55","asd");
109 waitAndTypeByName("field75","2014-04-04");
110 waitAndTypeByName("field82","13");
111 waitAndTypeByName("field83","24");
112 waitAndTypeByName("field57","1599");
113 waitAndTypeByName("field58","0");
114 waitAndTypeByName("field61","360001");
115 waitAndTypeByName("field62","@#");
116 waitAndTypeByName("field63","@/");
117 waitAndTypeByName("field64","@#12");
118 waitAndTypeByName("field65","a s");
119 waitAndTypeByName("field66","d");
120 waitAndTypeByName("field67","asd");
121 waitAndTypeByName("field68","1.a");
122 waitAndClickByXpath("//button[@id='usave']");
123 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field50']");
124 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field51']");
125 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field77']");
126 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field52']");
127 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field53']");
128 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field54']");
129 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field84']");
130 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field55']");
131 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field75']");
132 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field82']");
133 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field83']");
134 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field57']");
135 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field58']");
136 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field61']");
137 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field62']");
138 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field63']");
139 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field64']");
140 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field65']");
141 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field66']");
142 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field67']");
143 waitForElementPresentByXpath(ERROR_ELEMENT_XPATH+"/input[@name='field68']");
144
145 }
146
147 @Test
148 public void testServerSideTestViewBookmark() throws Exception {
149 testServerSideTestView();
150 passed();
151 }
152
153 @Test
154 public void testServerSideTestViewNav() throws Exception {
155 testServerSideTestView();
156 passed();
157 }
158 }