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 com.thoughtworks.selenium.SeleneseTestBase;
19  import org.kuali.rice.testtools.selenium.SmokeTestBase;
20  import org.junit.Test;
21  
22  import org.kuali.rice.testtools.selenium.ITUtil;
23  
24  public class LoginLogoutMultipleSmokeTest extends SmokeTestBase {
25  
26      /**
27       * "//div[@id='login-info']/strong[2]"
28       */
29      public static final String LOGIN_INFO_STRONG_2_XPATH = "//div[@id='login-info']/strong[2]";
30  
31      @Override
32      public void fail(String message) {
33          SeleneseTestBase.fail(message);
34      }
35  
36      @Override
37      protected String getBookmarkUrl() {
38          return ITUtil.PORTAL;
39      }
40  
41      @Override
42      protected void navigate() throws Exception {
43          waitAndClickMainMenu(this);
44          waitForPageToLoad();
45      }
46  
47      @Override
48      public String getTestUrl() {
49          return ITUtil.PORTAL;
50      }
51  
52      @Override
53      public String getUserName() {
54          return "admin";
55      }
56  
57      @Test
58      public void testMultipleLoginLogoutNav() throws Exception {
59          testMultipleLoginLogout();
60          passed();
61      }
62  
63      public void testMultipleLoginLogout() throws Exception {
64          SeleneseTestBase.assertEquals("Logged in User: admin",getTextByXpath("//div[@id='login-info']/strong[1]"));
65          SeleneseTestBase.assertEquals(Boolean.FALSE, isElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH));
66          waitAndTypeByName("backdoorId", "employee");
67          waitAndClickByXpath("//input[@value='Login']");
68          waitForPageToLoad();
69          assertElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH);
70          SeleneseTestBase.assertEquals("  Impersonating User: employee",getTextByXpath(LOGIN_INFO_STRONG_2_XPATH));
71          waitAndClickLogout();
72          SeleneseTestBase.assertEquals(Boolean.FALSE, isElementPresentByXpath(LOGIN_INFO_STRONG_2_XPATH));
73          waitAndClickLogout();
74          passed();
75      }
76  }