001    /*
002     * Copyright 2006-2012 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    
017    package edu.samplu.krad.configview;
018    
019    import com.thoughtworks.selenium.Selenium;
020    import junit.framework.Assert;
021    import org.junit.After;
022    import org.junit.Before;
023    import org.junit.Test;
024    import org.openqa.selenium.WebDriver;
025    import org.openqa.selenium.WebDriverBackedSelenium;
026    import org.openqa.selenium.firefox.FirefoxDriver;
027    
028    /**
029     * Selenium test that tests collections
030     *
031     * @author Kuali Rice Team (rice.collab@kuali.org)
032     */
033    public class CollectionsIT {
034        private Selenium selenium;
035    
036        @Before
037        public void setUp() throws Exception {
038            WebDriver driver = new FirefoxDriver();
039            String baseUrl = "http://localhost:8080/";
040            selenium = new WebDriverBackedSelenium(driver, baseUrl);
041    
042            // open Collections test view
043            selenium.open(
044                    "http://localhost:8080/kr-dev/kr-krad/uicomponents?viewId=ConfigurationTestView-Collections&methodToCall=start");
045            selenium.type("name=__login_user", "admin");
046            selenium.click("//input[@value='Login']");
047            selenium.waitForPageToLoad("30000");
048        }
049    
050        /**
051         * Test action column placement in table layout collections
052         */
053        @Test
054        public void testActionColumnPlacement() throws Exception {
055            // check if actions column RIGHT by default
056            Assert.assertTrue(selenium.isElementPresent("//div[@id='ConfigurationTestView-collection1']//tr[2]/td[6]//button[contains(.,\"delete\")]"));
057            // check if actions column is LEFT
058            Assert.assertTrue(selenium.isElementPresent("//div[@id='ConfigurationTestView-collection2']//tr[2]/td[1]//button[contains(.,\"delete\")]"));
059            // check if actions column is 3rd in a sub collection
060            Assert.assertTrue(selenium.isElementPresent("//div[@id='ConfigurationTestView-subCollection2_line0']//tr[2]/td[3]//button[contains(.,\"delete\")]"));
061        }
062    
063        @After
064        public void tearDown() throws Exception {
065            selenium.stop();
066        }
067    
068    }