Permalink
Browse files

+ New selenium test

git-svn-id: http://agilefant.googlecode.com/svn/trunk@4250 29784df9-99d5-7e28-3e6c-ac1830307ffc
  • Loading branch information...
1 parent 89f4396 commit f32032ed3d9e2ae7c137fdc0da1613ded0068e90 rjokelai committed Aug 9, 2010
Showing with 40 additions and 10 deletions.
  1. +1 −1 build.xml
  2. +39 −9 selenium/LoginTest.java
View
2 build.xml
@@ -519,7 +519,7 @@
<echo taskname="selenium-shutdown" message="DGF Errors during shutdown are expected" />
</target>
- <target name="selenium" depends="selenium-start, selenium-tests, selenium-stop" />
+ <target name="selenium" depends="sync-dbs, selenium-start, selenium-tests, selenium-stop" description="Drop-create agilefant and aeftest databases, and run selenium tests"/>
<target name="compile-selenium-tests" depends="compile">
<mkdir dir="${build.test.selenium.classes.dir}" />
View
48 selenium/LoginTest.java
@@ -6,23 +6,27 @@ public void setUp() throws Exception {
setUp("http://localhost:8080/", "*chrome");
}
- public void testFaultyLogin() throws Exception {
+ private void loginWithCredentials(String username, String password) {
selenium.open("/agilefant/login.jsp");
- selenium.type("username", "achmed");
- selenium.type("j_password", "abbas");
+ selenium.type("username", username);
+ selenium.type("j_password", password);
selenium.click("//input[@value='Log in']");
selenium.waitForPageToLoad("30000");
+ }
+
+ private void loginAsAdmin() {
+ loginWithCredentials("admin", "secret");
+ }
+
+ public void testFaultyLogin() throws Exception {
+ loginWithCredentials("achmed", "achmed");
verifyTrue(selenium
.isTextPresent("Invalid username or password, please try again."));
}
public void testLogin() throws Exception {
- selenium.open("/agilefant/login.jsp");
- selenium.type("username", "admin");
- selenium.type("j_password", "secret");
- selenium.click("_spring_security_remember_me");
- selenium.click("//input[@value='Log in']");
- selenium.waitForPageToLoad("30000");
+ loginAsAdmin();
+
for (int second = 0;; second++) {
if (second >= 60)
fail("timeout");
@@ -36,4 +40,30 @@ public void testLogin() throws Exception {
verifyTrue(selenium.isTextPresent("Agilefant help page"));
}
+
+ public void testCreateProduct() throws Exception {
+ loginAsAdmin();
+ selenium.click("createNewMenuLink");
+ selenium.click("createNewProduct");
+ for (int second = 0;; second++) {
+ if (second >= 60) fail("timeout");
+ try { if (selenium.isElementPresent("editor-2")) break; } catch (Exception e) {}
+ Thread.sleep(1000);
+ }
+
+ selenium.click("editor-2");
+ selenium.type("editor-2", "A New Product");
+ selenium.click("//button[@type='button']");
+
+ selenium.click("link=Products");
+ for (int second = 0;; second++) {
+ if (second >= 60) fail("timeout");
+ try { if (selenium.isElementPresent("link=A New Product")) break; } catch (Exception e) {}
+ Thread.sleep(1000);
+ }
+
+ selenium.click("link=A New Product");
+ selenium.waitForPageToLoad("30000");
+ verifyEquals("Product: A New Product", selenium.getText("//div[@id='bodyWrapper']/h2"));
+ }
}

0 comments on commit f32032e

Please sign in to comment.