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.mainmenu.test;
017    
018    import static org.junit.Assert.*;
019    
020    import org.junit.Test;
021    
022    import edu.samplu.common.ITUtil;
023    import edu.samplu.common.WebDriverLegacyITBase;
024    
025    public class MultipleLoginLogoutNavIT extends WebDriverLegacyITBase {
026    
027        /**
028         * "//div[@id='login-info']/strong[2]"
029         */
030        public static final String LOGIN_INFO_STRONG_2_XPATH = "//div[@id='login-info']/strong[2]";
031    
032        @Override
033        public String getTestUrl() {
034            return ITUtil.PORTAL;
035        }
036        @Override
037        public String getUserName() {
038            return "admin";
039        }
040        @Test
041        public void testMultipleLoginLogout() throws Exception {
042            waitAndClickMainMenu(this);
043            waitForPageToLoad();
044            assertEquals("Logged in User: admin",getTextByXpath("//div[@id='login-info']/strong[1]"));
045            assertEquals(Boolean.FALSE, isElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH));
046            waitAndTypeByName("backdoorId", "employee");
047            waitAndClickByXpath("//input[@value='Login']");
048            waitForPageToLoad();
049            assertElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH);
050            assertEquals("  Impersonating User: employee",getTextByXpath(LOGIN_INFO_STRONG_2_XPATH));
051            waitAndClickLogout();
052            assertEquals(Boolean.FALSE, isElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH));
053            waitAndClickLogout();
054            passed();
055        }
056    }