fix selenium tests for webapp-js

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1225529 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-12-29 13:53:01 +00:00
parent a3756190ef
commit 279afcd76a
3 changed files with 23 additions and 36 deletions

View File

@ -422,7 +422,7 @@
</property> </property>
</activation> </activation>
<properties> <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> </properties>
</profile> </profile>
<profile> <profile>

View File

@ -58,7 +58,7 @@ public class ArchivaAdminTest
getSelenium().open( baseUrl ); getSelenium().open( baseUrl );
getSelenium().refresh(); waitPage();
// if not admin user created create one // if not admin user created create one
if ( isElementVisible( "create-admin-link" ) ) if ( isElementVisible( "create-admin-link" ) )

View File

@ -29,6 +29,7 @@ import org.testng.annotations.Test;
* http://code.google.com/p/testng/source/browse/trunk/CHANGES.txt * http://code.google.com/p/testng/source/browse/trunk/CHANGES.txt
* Waiting 5.9 release. It's comming soon. * Waiting 5.9 release. It's comming soon.
*/ */
/** /**
* Based on LoginTest of Emmanuel Venisse test. * Based on LoginTest of Emmanuel Venisse test.
* *
@ -36,73 +37,59 @@ import org.testng.annotations.Test;
* @version $Id$ * @version $Id$
*/ */
@Test( groups = { "login" }, dependsOnGroups = {"about"}) @Test( groups = { "login" }, dependsOnGroups = { "about" } )
public class LoginTest public class LoginTest
extends AbstractArchivaTest extends AbstractArchivaTest
{ {
@Test(alwaysRun = true) @Test( alwaysRun = true )
public void testWithBadUsername() public void testWithBadUsername()
{ {
goToLoginPage(); goToLoginPage();
setFieldValue( "user-login-form-username", "badUsername" ); 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 ) @Test( dependsOnMethods = { "testWithBadUsername" }, alwaysRun = true )
public void testWithBadPassword() public void testWithBadPassword()
{ {
goToLoginPage(); goToLoginPage();
setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) ); setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
setFieldValue( "loginForm_password", "badPassword" ); setFieldValue( "user-login-form-password", "badPassword" );
getSelenium().click( "loginSubmit" ); clickLinkWithLocator( "modal-login-ok", true );
//getSelenium().waitForPageToLoad( maxWaitTimeInMs ); assertTextPresent( "You have entered an incorrect username and/or password" );
waitPage();
//assertTextPresent( "You have entered an incorrect username and/or password" );
//<ul class="errorMessage"><li><span>
assertElementPresent( "//ul[@class=\'errorMessage\']" );
} }
@Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true ) @Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true )
public void testWithEmptyUsername() public void testWithEmptyUsername()
{ {
goToLoginPage(); goToLoginPage();
setFieldValue( "loginForm_password", "password" ); setFieldValue( "user-login-form-password", "password" );
getSelenium().click( "loginSubmit" ); clickLinkWithLocator( "modal-login-ok", true );
//getSelenium().waitForPageToLoad( maxWaitTimeInMs );
waitPage();
//assertTextPresent( "User Name is required" ); //assertTextPresent( "User Name is required" );
assertElementPresent( "//tr[@errorFor=\'loginForm_username\']"); assertTextPresent( "This field is required." );
} }
@Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true ) @Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true )
public void testWithEmptyPassword() public void testWithEmptyPassword()
{ {
goToLoginPage(); goToLoginPage();
setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) ); setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
getSelenium().click( "loginSubmit" ); clickLinkWithLocator( "modal-login-ok", true );
//getSelenium().waitForPageToLoad( maxWaitTimeInMs );
waitPage();
//assertTextPresent( "You have entered an incorrect username and/or password" ); //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 ) @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun = true )
public void testWithCorrectUsernamePassword() public void testWithCorrectUsernamePassword()
{ {
goToLoginPage(); goToLoginPage();
setFieldValue( "loginForm_username", getProperty( "ADMIN_USERNAME" ) ); setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
setFieldValue( "loginForm_password", getProperty( "ADMIN_PASSWORD" ) ); setFieldValue( "user-login-form-password", getProperty( "ADMIN_PASSWORD" ) );
getSelenium().click( "loginSubmit" ); clickLinkWithLocator( "modal-login-ok", true );
//getSelenium().waitForPageToLoad( maxWaitTimeInMs );
waitPage(); assertUserLoggedIn( getProperty( "ADMIN_USERNAME" ) );
//assertTextPresent( "Logout" );
assertElementPresent( "logoutLink" );
//assertTextPresent( "Edit Details" );
assertElementPresent( "editUserLink" );
assertTextPresent( getProperty( "ADMIN_USERNAME" ) );
} }
@BeforeTest @BeforeTest