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     */
016    package edu.samplu;
017    
018    import com.thoughtworks.selenium.SeleneseTestBase;
019    import org.kuali.rice.testtools.selenium.SmokeTestBase;
020    import org.junit.Test;
021    
022    import org.kuali.rice.testtools.selenium.ITUtil;
023    
024    public class LoginLogoutMultipleSmokeTest extends SmokeTestBase {
025    
026        /**
027         * "//div[@id='login-info']/strong[2]"
028         */
029        public static final String LOGIN_INFO_STRONG_2_XPATH = "//div[@id='login-info']/strong[2]";
030    
031        @Override
032        public void fail(String message) {
033            SeleneseTestBase.fail(message);
034        }
035    
036        @Override
037        protected String getBookmarkUrl() {
038            return ITUtil.PORTAL;
039        }
040    
041        @Override
042        protected void navigate() throws Exception {
043            waitAndClickMainMenu(this);
044            waitForPageToLoad();
045        }
046    
047        @Override
048        public String getTestUrl() {
049            return ITUtil.PORTAL;
050        }
051    
052        @Override
053        public String getUserName() {
054            return "admin";
055        }
056    
057        @Test
058        public void testMultipleLoginLogoutNav() throws Exception {
059            testMultipleLoginLogout();
060            passed();
061        }
062    
063        public void testMultipleLoginLogout() throws Exception {
064            SeleneseTestBase.assertEquals("Logged in User: admin",getTextByXpath("//div[@id='login-info']/strong[1]"));
065            SeleneseTestBase.assertEquals(Boolean.FALSE, isElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH));
066            waitAndTypeByName("backdoorId", "employee");
067            waitAndClickByXpath("//input[@value='Login']");
068            waitForPageToLoad();
069            assertElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH);
070            SeleneseTestBase.assertEquals("  Impersonating User: employee",getTextByXpath(LOGIN_INFO_STRONG_2_XPATH));
071            waitAndClickLogout();
072            SeleneseTestBase.assertEquals(Boolean.FALSE, isElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH));
073            waitAndClickLogout();
074            passed();
075        }
076    }