1 package org.itracker.selenium;
2
3 import java.io.IOException;
4 import org.junit.Test;
5
6
7
8
9
10
11
12 public class LogoutTest extends AbstractSeleniumTestCase {
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 @Test
31 public void testLoginAndLogout() throws IOException {
32 SeleniumManager.closeSession(selenium);
33 selenium.open("http://" + applicationHost + ":" + applicationPort + "/"
34 + applicationPath + "/portalhome.do");
35
36 assertFalse(selenium.isElementPresent("id"));
37 assertTrue(selenium.isElementPresent("login"));
38 assertTrue(selenium.isElementPresent("password"));
39 assertTrue(selenium.isElementPresent("xpath=//.[@type='submit']"));
40 selenium.type("login", "user_test1");
41 selenium.type("password", "user_test1");
42 selenium.click("xpath=//.[@type='submit']");
43 selenium.waitForPageToLoad(SE_TIMEOUT);
44
45 assertTrue(selenium.isElementPresent("id"));
46 assertTrue(selenium.isElementPresent("logoff"));
47 selenium.click("logoff");
48 selenium.waitForPageToLoad(SE_TIMEOUT);
49
50 assertFalse(selenium.isElementPresent("id"));
51 assertTrue(selenium.isElementPresent("login"));
52 assertTrue(selenium.isElementPresent("password"));
53 selenium.open("http://" + applicationHost + ":" + applicationPort + "/"
54 + applicationPath + "/portalhome.do");
55
56 assertFalse(selenium.isElementPresent("id"));
57 assertTrue(selenium.isElementPresent("login"));
58 assertTrue(selenium.isElementPresent("password"));
59 }
60
61 @Override
62 protected String[] getDataSetFiles() {
63 return new String[]{
64 "dataset/languagebean_init_dataset.xml",
65 "dataset/languagebean_dataset.xml",
66 "dataset/userpreferencesbean_dataset.xml",
67 "dataset/userbean_dataset.xml"
68 };
69 }
70
71 @Override
72 protected String[] getConfigLocations() {
73 return new String[]{ "application-context.xml"};
74 }
75 }