View Javadoc

1   package org.itracker.selenium;
2   
3   import java.io.IOException;
4   import org.junit.Test;
5   
6   /**
7    * Check the content of PortalHome page with some data available.
8    * 
9    * @author Andrey Sergievskiy <seas@andreysergievskiy.com>
10   */
11  public class ViewPortalHomeTest extends AbstractSeleniumTestCase {
12      /**
13       * Verifies the successfull login case with valid login/password.
14       * 
15       * 0. Exit all available http sessions.
16       * 1. Login into the system with particular login (admin_test1).
17       * 2. Check that "Unassigned Issues" section is present at the page.
18       * 3. Check that number of unassigned issues is 2 (as we defined in
19       *    database before running this test).
20       * 4. Check all unassigned issues we expect to be in the system are
21       *    shown at the page (check them one by one).
22       * 5. Check that "Created Issues" section is present at the page.
23       * 6. Check that number of created issues is 4 (as we defined in
24       *     database before running this test).
25       * 7. Check all all create issues we expect to be in the system are
26       *    shown at the page (check them one by one).
27       * 8. Check that "Watched Issues" section is present at the page.
28       * 9. Check that number of watched items is 0.
29       * @throws java.io.IOException
30       */
31      @Test
32      public void testViewHomePage() throws IOException {
33          SeleniumManager.closeSession(selenium);
34          selenium.open("http://" + applicationHost + ":" + applicationPort + "/"
35                  + applicationPath);
36  
37          assertFalse(selenium.isElementPresent("id"));
38          assertTrue(selenium.isElementPresent("login"));
39          assertTrue(selenium.isElementPresent("password"));
40          assertTrue(selenium.isElementPresent("xpath=//.[@type='submit']"));
41          selenium.type("login", "admin_test1");
42          selenium.type("password", "admin_test1");
43          selenium.click("xpath=//.[@type='submit']");
44          selenium.waitForPageToLoad(SE_TIMEOUT);
45  
46          assertElementPresent("id");
47          assertElementPresent("id=unassignedIssues");
48          assertEquals("count //tr[starts-with(@id, 'unassignedIssue.')]", 2, selenium.getXpathCount("//tr[starts-with(@id, 'unassignedIssue.')]"));
49          assertElementPresent("xpath=//tr[starts-with(@id,'unassignedIssue.')]/td[3][text()='1']/../td[5][text()='test_name']/../td[11][text()='test_description']");
50          assertElementPresent("xpath=//tr[starts-with(@id,'unassignedIssue.')]/td[3][text()='2']/../td[5][text()='test_name']/../td[11][text()='test_description 2']");
51          
52          assertElementPresent("id=createdIssues");
53          assertEquals("count //tr[starts-with(@id, 'createdIssue.')]", 4, selenium.getXpathCount("//tr[starts-with(@id, 'createdIssue.')]"));
54          assertElementPresent("xpath=//tr[starts-with(@id,'createdIssue.')]/td[3][text()='1']/../td[5][text()='test_name']/../td[11][text()='test_description']");
55          assertElementPresent("xpath=//tr[starts-with(@id,'createdIssue.')]/td[3][text()='2']/../td[5][text()='test_name']/../td[11][text()='test_description 2']");
56          assertElementPresent("xpath=//tr[starts-with(@id,'createdIssue.')]/td[3][text()='3']/../td[5][text()='test_name']/../td[11][text()='test_description 3']");
57          assertElementPresent("xpath=//tr[starts-with(@id,'createdIssue.')]/td[3][text()='4']/../td[5][text()='test_name']/../td[11][text()='test_description 4']");
58          
59          assertElementPresent("id=watchedIssues");
60          assertFalse("unexpected watchedIssue", selenium.isElementPresent("//tr[starts-with(@id, 'watchedIssue.')]"));
61      }
62      
63      @Override
64      protected String[] getDataSetFiles() {
65          return new String[]{
66                  "dataset/languagebean_init_dataset.xml",
67                  "dataset/languagebean_dataset.xml",
68                  "dataset/userpreferencesbean_dataset.xml",
69                  "dataset/userbean_dataset.xml",
70                  "dataset/projectbean_dataset.xml",
71                  "dataset/permissionbean_dataset.xml",
72                  "dataset/versionbean_dataset.xml",
73                  "dataset/issuebean_dataset.xml"
74          };
75      }
76  
77      @Override
78      protected String[] getConfigLocations() {
79          return new String[]{ "application-context.xml"};
80      }
81  }