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