fix selenium issues i18n

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1174421 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-09-22 22:19:00 +00:00
parent 0157bc252d
commit 604d5117e8
3 changed files with 47 additions and 19 deletions

View File

@ -82,7 +82,7 @@ public class ArtifactManagementTest
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true ) @Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
public void testAddArtifactNoFilePath() public void testAddArtifactNoFilePath()
{ {
addArtifact( getGroupId(), getArtifactId(), getVersion(), getPackaging(), " ", getRepositoryId(), false ); addArtifact( getGroupId(), getArtifactId(), getVersion(), getPackaging(), " ", getRepositoryId(), true );
assertTextPresent( "Please add a file to upload." ); assertTextPresent( "Please add a file to upload." );
} }

View File

@ -204,10 +204,12 @@ public abstract class AbstractArchivaTest
public void assertUserRolesPage() public void assertUserRolesPage()
{ {
assertPage( "Apache Archiva \\ [Admin] User Edit" ); //assertPage( "Apache Archiva \\ [Admin] User Edit" );
assertTextPresent( "[Admin] User Roles" ); //[Admin] Rôles de l'utilisateur
assertTextPresent( "Username" );
assertTextPresent( "Full Name" ); assertTextPresent( "[Admin] User Roles", "[Admin] R\u00F4les de l'utilisateur" );
assertTextPresent( "Username", "Nom d'utilisateur" );
assertTextPresent( "Full Name", "Nom complet" );
String userRoles = String userRoles =
"Guest,Registered User,System Administrator,User Administrator,Global Repository Observer,Global Repository Manager,Repository Observer,Repository Manager,internal"; "Guest,Registered User,System Administrator,User Administrator,Global Repository Observer,Global Repository Manager,Repository Observer,Repository Manager,internal";
String[] arrayRole = userRoles.split( "," ); String[] arrayRole = userRoles.split( "," );
@ -219,11 +221,10 @@ public abstract class AbstractArchivaTest
public void assertDeleteUserPage( String username ) public void assertDeleteUserPage( String username )
{ {
assertPage( "Apache Archiva \\ [Admin] User Delete" ); // TODO assertTextPresent( "[Admin] User Delete", "[Admin] Suppression de l'utilisateur", "L'utilisateur suivant va \u00EAtre supprim\u00E9:" );
assertTextPresent( "[Admin] User Delete" );
assertTextPresent( "The following user will be deleted:" ); assertTextPresent( "The following user will be deleted:" );
assertTextPresent( "Username: " + username ); assertTextPresent( "Username: " + username , "Nom d'utilisateur:" + username);
assertButtonWithValuePresent( "Delete User" ); assertButtonWithIdPresent( "userDeleteSubmit" );
} }
public void createUser( String userName, String fullName, String email, String password, boolean valid ) public void createUser( String userName, String fullName, String email, String password, boolean valid )
@ -236,7 +237,8 @@ public abstract class AbstractArchivaTest
{ {
// login( getAdminUsername() , getAdminPassword() ); // login( getAdminUsername() , getAdminPassword() );
getSelenium().open( "/archiva/security/userlist.action" ); getSelenium().open( "/archiva/security/userlist.action" );
clickButtonWithValue( "Create New User" ); clickButtonWithLocator( "userCreateButton", true );
//clickButtonWithValue( "Create New User" );
assertCreateUserPage(); assertCreateUserPage();
setFieldValue( "user.username", userName ); setFieldValue( "user.username", userName );
setFieldValue( "user.fullName", fullName ); setFieldValue( "user.fullName", fullName );
@ -246,7 +248,9 @@ public abstract class AbstractArchivaTest
submit(); submit();
assertUserRolesPage(); assertUserRolesPage();
clickButtonWithValue( "Submit" );
//clickButtonWithValue( "Submit" );
clickButtonWithName( "submitRolesButton", true );
if ( valid ) if ( valid )
{ {
@ -382,19 +386,21 @@ public abstract class AbstractArchivaTest
public void assertCreateUserPage() public void assertCreateUserPage()
{ {
assertPage( "Apache Archiva \\ [Admin] User Create" ); //assertPage( "Apache Archiva \\ [Admin] User Create" );
assertTextPresent( "[Admin] User Create" ); //assertTextPresent( "[Admin] User Create" );
assertTextPresent( "Username*:" ); assertTextPresent( "Username*:", "Nom d'utilisateur*:" );
assertElementPresent( "user.username" ); assertElementPresent( "user.username" );
assertTextPresent( "Full Name*:" ); assertTextPresent( "Full Name*:", "Nom complet*:" );
assertElementPresent( "user.fullName" ); assertElementPresent( "user.fullName" );
assertTextPresent( "Email Address*:" ); assertTextPresent( "Email Address*:", "Adresse email*:" );
assertElementPresent( "user.email" ); assertElementPresent( "user.email" );
assertTextPresent( "Password*:" ); assertTextPresent( "Password*:", "Mot de passe*:" );
assertElementPresent( "user.password" ); assertElementPresent( "user.password" );
assertTextPresent( "Confirm Password*:" ); assertTextPresent( "Confirm Password*:", "Confirmer le mot de passe*" );
assertElementPresent( "user.confirmPassword" ); assertElementPresent( "user.confirmPassword" );
assertButtonWithValuePresent( "Create User" ); //assertButtonWithValuePresent( "Create User" );
//assertButtonWithIdPresent( "userCreateSubmit" );
assertElementNotPresent( "userCreateSubmit" );
} }
public void assertLeftNavMenuWithRole( String role ) public void assertLeftNavMenuWithRole( String role )

View File

@ -170,6 +170,23 @@ public abstract class AbstractSeleniumTest
Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." ); Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." );
} }
/**
* one of text args must be in the page so use en and fr text (olamy use en locale :-) )
*
* @param texts
*/
public void assertTextPresent( String... texts )
{
boolean present = false;
StringBuilder sb = new StringBuilder();
for ( String text : texts )
{
present = present || getSelenium().isTextPresent( text );
sb.append( " " + text + " " );
}
Assert.assertTrue( present, "'one of the following test " + sb.toString() + "' isn't present." );
}
public void assertTextNotPresent( String text ) public void assertTextNotPresent( String text )
{ {
Assert.assertFalse( getSelenium().isTextPresent( text ), "'" + text + "' is present." ); Assert.assertFalse( getSelenium().isTextPresent( text ), "'" + text + "' is present." );
@ -319,6 +336,11 @@ public abstract class AbstractSeleniumTest
return isElementPresent( "//button[@id='" + text + "']" ) || isElementPresent( "//input[@id='" + text + "']" ); return isElementPresent( "//button[@id='" + text + "']" ) || isElementPresent( "//input[@id='" + text + "']" );
} }
public void clickButtonWithName( String text, boolean wait )
{
clickLinkWithXPath( "//input[@name='" + text + "']", wait );
}
public void clickButtonWithValue( String text ) public void clickButtonWithValue( String text )
{ {
clickButtonWithValue( text, true ); clickButtonWithValue( text, true );