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;
17  
18  import static org.junit.Assert.*;
19  
20  import edu.samplu.common.SmokeTestBase;
21  import org.junit.Assert;
22  import org.junit.Test;
23  
24  import edu.samplu.common.ITUtil;
25  
26  public class LoginLogoutMultipleSmokeTest extends SmokeTestBase {
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      protected String getBookmarkUrl() {
40          return ITUtil.PORTAL;
41      }
42  
43      @Override
44      protected void navigate() throws Exception {
45          waitAndClickMainMenu(this);
46          waitForPageToLoad();
47      }
48  
49      @Override
50      public String getTestUrl() {
51          return ITUtil.PORTAL;
52      }
53  
54      @Override
55      public String getUserName() {
56          return "admin";
57      }
58  
59      @Test
60      public void testMultipleLoginLogoutNav() throws Exception {
61          testMultipleLoginLogout();
62          passed();
63      }
64  
65      public void testMultipleLoginLogout() throws Exception {
66          assertEquals("Logged in User: admin",getTextByXpath("//div[@id='login-info']/strong[1]"));
67          assertEquals(Boolean.FALSE, isElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH));
68          waitAndTypeByName("backdoorId", "employee");
69          waitAndClickByXpath("//input[@value='Login']");
70          waitForPageToLoad();
71          assertElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH);
72          assertEquals("  Impersonating User: employee",getTextByXpath(LOGIN_INFO_STRONG_2_XPATH));
73          waitAndClickLogout();
74          assertEquals(Boolean.FALSE, isElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH));
75          waitAndClickLogout();
76          passed();
77      }
78  }