View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package edu.samplu.mainmenu.test;
17  
18  import static org.junit.Assert.*;
19  
20  import org.junit.Assert;
21  import org.junit.Test;
22  
23  import edu.samplu.common.ITUtil;
24  import edu.samplu.common.WebDriverLegacyITBase;
25  
26  public class MultipleLoginLogoutNavIT extends WebDriverLegacyITBase {
27  
28      /**
29       * "//div[@id='login-info']/strong[2]"
30       */
31      public static final String LOGIN_INFO_STRONG_2_XPATH = "//div[@id='login-info']/strong[2]";
32  
33      @Override
34      public void fail(String message) {
35          Assert.fail(message);
36      }
37  
38      @Override
39      public String getTestUrl() {
40          return ITUtil.PORTAL;
41      }
42  
43      @Override
44      public String getUserName() {
45          return "admin";
46      }
47  
48      @Test
49      public void testMultipleLoginLogout() throws Exception {
50          waitAndClickMainMenu(this);
51          waitForPageToLoad();
52          assertEquals("Logged in User: admin",getTextByXpath("//div[@id='login-info']/strong[1]"));
53          assertEquals(Boolean.FALSE, isElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH));
54          waitAndTypeByName("backdoorId", "employee");
55          waitAndClickByXpath("//input[@value='Login']");
56          waitForPageToLoad();
57          assertElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH);
58          assertEquals("  Impersonating User: employee",getTextByXpath(LOGIN_INFO_STRONG_2_XPATH));
59          waitAndClickLogout();
60          assertEquals(Boolean.FALSE, isElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH));
61          waitAndClickLogout();
62          passed();
63      }
64  }