View Javadoc

1   package org.itracker.selenium;
2   
3   import java.io.IOException;
4   import org.junit.Test;
5   
6   /**
7    * Verifies the functionality of View Issue page.
8    * 
9    * @author Andrey Sergievskiy <seas@andreysergievskiy.com>
10   */
11  public class ViewIssueTest extends AbstractSeleniumTestCase {
12      /**
13       * 1. Enter the system with admin_test1 user login.
14       * 2. Goto "Projects List" page.
15       * 3. For project "test_name", click "View" link.
16       * 4. At "View Issues" page, for Issue 1, click "View" link.
17       * 5. At appeared page (View Issue), compare description and
18       *    current owner to expected values.
19       * @throws java.io.IOException
20       */
21      @Test
22      public void testViewIssue1() throws IOException {
23          closeSession();
24          selenium.open("http://" + applicationHost + ":" + applicationPort + "/"
25                  + applicationPath);
26  
27          assertTrue(selenium.isElementPresent("//.[@name='login']"));
28          assertTrue(selenium.isElementPresent("//.[@name='password']"));
29          assertTrue(selenium.isElementPresent("//.[@value='Login']"));
30          selenium.type("//.[@name='login']", "admin_test1");
31          selenium.type("//.[@name='password']", "admin_test1");
32          selenium.click("//.[@value='Login']");
33          selenium.waitForPageToLoad(SE_TIMEOUT);
34          
35          selenium.click("listprojects");
36          selenium.waitForPageToLoad(SE_TIMEOUT);
37          
38          // Click view issue link (usually it's named "View").
39          assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'project.')]/td[3][text()='test_name']/../td[1]/a[1]"));
40          selenium.click("//tr[starts-with(@id, 'project.')]/td[3][text()='test_name']/../td[1]/a[1]");
41          selenium.waitForPageToLoad(SE_TIMEOUT);
42          
43          assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'issue.')]/td[3][text()='1']/../td[11][text()='test_description']/../td[1]/a[1]"));
44          selenium.click("//tr[starts-with(@id, 'issue.')]/td[3][text()='1']/../td[11][text()='test_description']/../td[1]/a[1]");
45          selenium.waitForPageToLoad(SE_TIMEOUT);
46          
47          assertEquals("test_description", selenium.getText("description"));
48          assertEquals("admin firstname admin lastname", selenium.getText("ownerName"));
49      }
50      
51      /**
52       * 1. Enter the system with admin_test1 user login.
53       * 2. Goto "Projects List" page.
54       * 3. For project "test_name", click "View" link.
55       * 4. At "View Issues" page, for Issue 2, click "View" link.
56       * 5. At appeared page (View Issue), compare description and
57       *    current owner to expected values.
58       * @throws java.io.IOException
59       */
60      @Test
61      public void testViewIssue2() throws IOException {
62          closeSession();
63          selenium.open("http://" + applicationHost + ":" + applicationPort + "/"
64                  + applicationPath);
65  
66          assertTrue(selenium.isElementPresent("//.[@name='login']"));
67          assertTrue(selenium.isElementPresent("//.[@name='password']"));
68          assertTrue(selenium.isElementPresent("//.[@value='Login']"));
69          selenium.type("//.[@name='login']", "admin_test1");
70          selenium.type("//.[@name='password']", "admin_test1");
71          selenium.click("//.[@value='Login']");
72          selenium.waitForPageToLoad(SE_TIMEOUT);
73          
74          selenium.click("listprojects");
75          selenium.waitForPageToLoad(SE_TIMEOUT);
76          
77          // Click view issue link (usually it's named "View").
78          assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'project.')]/td[3][text()='test_name']/../td[1]/a[1]"));
79          selenium.click("//tr[starts-with(@id, 'project.')]/td[3][text()='test_name']/../td[1]/a[1]");
80          selenium.waitForPageToLoad(SE_TIMEOUT);
81          
82          assertTrue(selenium.isElementPresent("//tr[starts-with(@id, 'issue.')]/td[3][text()='2']/../td[11][text()='test_description 2']/../td[1]/a[1]"));
83          selenium.click("//tr[starts-with(@id, 'issue.')]/td[3][text()='2']/../td[11][text()='test_description 2']/../td[1]/a[1]");
84          selenium.waitForPageToLoad(SE_TIMEOUT);
85          
86          assertEquals("test_description 2", selenium.getText("description"));
87          assertEquals("admin firstname admin lastname", selenium.getText("ownerName"));
88      }
89      
90      @Override
91      protected String[] getDataSetFiles() {
92          return new String[]{
93                  "dataset/languagebean_init_dataset.xml",
94                  "dataset/languagebean_dataset.xml",
95                  "dataset/userpreferencesbean_dataset.xml",
96                  "dataset/userbean_dataset.xml",
97                  "dataset/projectbean_dataset.xml",
98                  "dataset/permissionbean_dataset.xml",
99                  "dataset/versionbean_dataset.xml",
100                 "dataset/issuebean_dataset.xml"
101         };
102     }
103 
104     @Override
105     protected String[] getConfigLocations() {
106         return new String[]{ "application-context.xml"};
107     }
108 }