PageRenderTime 17ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/src/test/java/org/sigmah/endtoend/CreateDatabaseTest.java

http://sigma-h.googlecode.com/
Java | 61 lines | 42 code | 14 blank | 5 comment | 0 complexity | 74296c5ab3ae0d360fcb36a7c8c7850a MD5 | raw file
 1/*
 2 * All Sigmah code is released under the GNU General Public License v3
 3 * See COPYRIGHT.txt and LICENSE.txt.
 4 */
 5
 6package org.sigmah.endtoend;
 7
 8import org.junit.Test;
 9import org.openqa.selenium.Cookie;
10import org.sigmah.endtoend.page.GxtApplication;
11import org.sigmah.endtoend.page.GxtComponent;
12
13import static org.sigmah.endtoend.xpath.XPath.*;
14import static org.sigmah.endtoend.xpath.ext.GxtXPath.isComboBox;
15import static org.sigmah.endtoend.xpath.ext.GxtXPath.isToolbar;
16
17public class CreateDatabaseTest extends EndToEndTestCase {
18
19
20    @Test
21    public void canCreateDatabase() {
22        dataLoader.load("/dbunit/createdatabase.db.xml");
23
24        navigateToAppWithAuthorization();
25
26        GxtApplication app = getApp();
27        app.clickOn("Setup");
28        app.find(
29                descendant(isToolbar()),
30                descendant(havingTextEqualTo("New Database"))
31        ).click();
32
33        GxtComponent window = app.activeWindow();
34        window.find(
35                descendant(havingTextEqualTo("Name:")),
36                following(element("input"))
37        ).sendKeys("My New Database");
38
39        window.find(
40                descendant(havingTextEqualTo("Description:")),
41                following(element("input"))
42        ).sendKeys("A full description of my new database");
43
44        window.find(
45                descendant(havingTextEqualTo("Country:")),
46                following(isComboBox())
47        ).asComboBox().trigger("Haiti");
48
49        window.clickOn("Save");
50
51        // should now appear in grid
52        app.find(
53                descendant(havingTextEqualTo("A full description of my new database"))
54        );
55    }
56
57    private void addAuthCookie() {
58        removeAuthCookie();
59        driver.manage().addCookie(new Cookie.Builder("authToken", "XYZ123").domain("localhost").build());
60    }
61}