001/**
002 * Copyright 2005-2013 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 */
016package edu.samplu.krad.library.validation;
017
018import org.junit.Test;
019
020import edu.samplu.common.SmokeTestBase;
021import org.openqa.selenium.By;
022
023/**
024 * @author Kuali Rice Team (rice.collab@kuali.org)
025 */
026public class DemoLibraryValidationCaseConstraintsSmokeTest extends SmokeTestBase {
027
028    /**
029     * /kr-krad/kradsampleapp?viewId=Demo-CaseConstraint-View&methodToCall=start
030     */
031    public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-CaseConstraint-View&methodToCall=start";
032
033    @Override
034    protected String getBookmarkUrl() {
035        return BOOKMARK_URL;
036    }
037
038    @Override
039    protected void navigate() throws Exception {
040        waitAndClickById("Demo-LibraryLink", "");
041        waitAndClickByLinkText("Validation");
042        waitAndClickByLinkText("Case Constraint");
043    }
044
045    protected void testValidationCaseConstraintsBasic() throws Exception {
046       //Scenario-1
047       waitAndClickByXpath("//input[@type='radio' and @value='case1']");
048       waitAndTypeByName("inputField1","");
049       waitAndTypeByName("inputField2","");
050       isVisible(By.xpath("//li[@class='uif-errorMessageItem-field']"));
051      
052       //Scenario-2
053       waitAndClickByXpath("//input[@type='radio' and @value='case2']");
054       waitAndTypeByName("inputField1","a_+");
055       waitAndTypeByName("inputField2","");
056       fireMouseOverEventByName("inputField1");
057       isVisible(By.xpath("//li[@class='uif-errorMessageItem-field']"));
058       
059       //Scenario-3
060       waitAndClickByXpath("//input[@type='radio' and @value='case3']");
061       waitAndTypeByName("inputField2","567823");
062       waitAndTypeByName("inputField1","");
063       fireMouseOverEventByName("inputField2");
064        isVisible(By.xpath("//li[@class='uif-errorMessageItem-field']"));
065       
066       //Scenario-4
067       waitAndClickByXpath("//input[@type='radio' and @value='case4']");
068       waitAndTypeByName("inputField3","a");
069       waitAndTypeByName("inputField4","");
070       waitAndTypeByName("inputField3","");
071       fireMouseOverEventByName("inputField4");
072       isVisible(By.xpath("//li[@class='uif-errorMessageItem-field']"));
073    }
074    
075    protected void testValidationCaseConstraintsNested() throws Exception {
076       waitAndClickByLinkText("Nested Example");
077       
078       //Scenario-1
079       waitAndTypeByName("inputField5","a");
080       waitAndTypeByName("inputField7","");
081       waitAndTypeByName("inputField6","");
082       assertElementPresentByXpath("//input[@name='inputField7' and @class='uif-textControl dependsOn-inputField5 dependsOn-inputField6 error']");
083    }
084    
085    @Test
086    public void testValidationCaseConstraintsBookmark() throws Exception {
087        testValidationCaseConstraintsBasic();
088        testValidationCaseConstraintsNested();
089        passed();
090    }
091
092    @Test
093    public void testValidationCaseConstraintsNav() throws Exception {
094        testValidationCaseConstraintsBasic();
095        testValidationCaseConstraintsNested();
096        passed();
097    }
098}