]> source.dussan.org Git - archiva.git/commitdiff
fix selenium tests for webapp-js
authorOlivier Lamy <olamy@apache.org>
Thu, 29 Dec 2011 13:53:01 +0000 (13:53 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 29 Dec 2011 13:53:01 +0000 (13:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1225529 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-test-js/pom.xml
archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/ArchivaAdminTest.java
archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/LoginTest.java

index c932399d430c20d00457103d3abf7953f21f1b68..3fbf0ace54f21b08c6d34b01bfa07ec337c40254 100644 (file)
         </property>
       </activation>
       <properties>
-        <baseUrl>http://localhost:${container.test.port}/archiva/index.html</baseUrl>
+        <baseUrl>http://localhost:${container.test.port}/archiva/index.html?request_lang=en</baseUrl>
       </properties>
     </profile>
     <profile>
index 96de18c9c1df93f6f1300640dc49fda4868dc7a2..84bdfef1be6971431b94ce0f5943ef3ead08ff5c 100644 (file)
@@ -58,7 +58,7 @@ public class ArchivaAdminTest
 
         getSelenium().open( baseUrl );
 
-        getSelenium().refresh();
+        waitPage();
 
         // if not admin user created create one
         if ( isElementVisible( "create-admin-link" ) )
index a1ba7326ac14564033c30fd1dbd24cccebd42d8c..b967a70fcc829dd5ebf0451c9e9b1c9cc56de00d 100644 (file)
@@ -29,80 +29,67 @@ import org.testng.annotations.Test;
  * http://code.google.com/p/testng/source/browse/trunk/CHANGES.txt
  * Waiting 5.9 release. It's comming soon.
  */
+
 /**
  * Based on LoginTest of Emmanuel Venisse test.
- * 
+ *
  * @author José Morales Martínez
  * @version $Id$
  */
 
-@Test( groups = { "login" }, dependsOnGroups = {"about"})
+@Test( groups = { "login" }, dependsOnGroups = { "about" } )
 public class LoginTest
     extends AbstractArchivaTest
 {
-    @Test(alwaysRun = true)
+    @Test( alwaysRun = true )
     public void testWithBadUsername()
     {
         goToLoginPage();
         setFieldValue( "user-login-form-username", "badUsername" );
+        clickLinkWithLocator( "modal-login-ok", true );
+        assertTextPresent( "This field is required." );
 
-        waitPage();
-        assertElementPresent( "//ul[@class=\'errorMessage\']" );
-        //assertTextPresent( "You have entered an incorrect username and/or password" );
     }
 
     @Test( dependsOnMethods = { "testWithBadUsername" }, alwaysRun = true )
     public void testWithBadPassword()
     {
         goToLoginPage();
-        setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
-        setFieldValue( "loginForm_password", "badPassword" );
-        getSelenium().click( "loginSubmit" );
-        //getSelenium().waitForPageToLoad( maxWaitTimeInMs );
-        waitPage();
-        //assertTextPresent( "You have entered an incorrect username and/or password" );
-        //<ul class="errorMessage"><li><span>
-        assertElementPresent( "//ul[@class=\'errorMessage\']" );
+        setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
+        setFieldValue( "user-login-form-password", "badPassword" );
+        clickLinkWithLocator( "modal-login-ok", true );
+        assertTextPresent( "You have entered an incorrect username and/or password" );
     }
 
     @Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true )
     public void testWithEmptyUsername()
     {
         goToLoginPage();
-        setFieldValue( "loginForm_password", "password" );
-        getSelenium().click( "loginSubmit" );
-        //getSelenium().waitForPageToLoad( maxWaitTimeInMs );
-        waitPage();
+        setFieldValue( "user-login-form-password", "password" );
+        clickLinkWithLocator( "modal-login-ok", true );
         //assertTextPresent( "User Name is required" );
-        assertElementPresent( "//tr[@errorFor=\'loginForm_username\']");
+        assertTextPresent( "This field is required." );
     }
 
     @Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true )
     public void testWithEmptyPassword()
     {
         goToLoginPage();
-        setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
-        getSelenium().click( "loginSubmit" );
-        //getSelenium().waitForPageToLoad( maxWaitTimeInMs );
-        waitPage();
+        setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
+        clickLinkWithLocator( "modal-login-ok", true );
         //assertTextPresent( "You have entered an incorrect username and/or password" );
-        assertElementPresent( "//ul[@class=\'errorMessage\']" );
+        assertTextPresent( "This field is required." );
     }
 
     @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun = true )
     public void testWithCorrectUsernamePassword()
     {
         goToLoginPage();
-        setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) );
-        setFieldValue( "loginForm_password", getProperty( "ADMIN_PASSWORD" ) );
-        getSelenium().click( "loginSubmit" );
-        //getSelenium().waitForPageToLoad( maxWaitTimeInMs );
-        waitPage();
-        //assertTextPresent( "Logout" );
-        assertElementPresent( "logoutLink" );
-        //assertTextPresent( "Edit Details" );
-        assertElementPresent( "editUserLink" );
-        assertTextPresent( getProperty( "ADMIN_USERNAME" ) );
+        setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
+        setFieldValue( "user-login-form-password", getProperty( "ADMIN_PASSWORD" ) );
+        clickLinkWithLocator( "modal-login-ok", true );
+
+        assertUserLoggedIn( getProperty( "ADMIN_USERNAME" ) );
     }
 
     @BeforeTest