summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-webapp-test
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-06-21 16:40:39 +0000
committerOlivier Lamy <olamy@apache.org>2011-06-21 16:40:39 +0000
commita26b625c437b646700ed954c7e261093498dc859 (patch)
treeab1e1499db4d7f189571f990d145f212549b4284 /archiva-modules/archiva-web/archiva-webapp-test
parentfeb736e52948db61dd97f0d512590100a8199527 (diff)
downloadarchiva-a26b625c437b646700ed954c7e261093498dc859.tar.gz
archiva-a26b625c437b646700ed954c7e261093498dc859.zip
push more work on selenium test using id rather than labels
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1138081 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web/archiva-webapp-test')
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/pom.xml6
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArchivaAdminTest.java7
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java22
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java18
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java20
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java19
6 files changed, 63 insertions, 29 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
index c3039ae97..5dce4b304 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
+++ b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml
@@ -38,7 +38,7 @@
<cargo.install.dir>cargo-installs</cargo.install.dir>
<maxWaitTimeInMs>60000</maxWaitTimeInMs>
<!-- TODO: review how appropriate the memory settings are - should work with less -->
- <cargo.jvm.args>-Xmx512m -XX:MaxPermSize=256m -Duser.language=en</cargo.jvm.args>
+ <cargo.jvm.args>-Xmx512m -XX:MaxPermSize=256m</cargo.jvm.args>
<seleniumPluginVersion>2.0-SNAPSHOT</seleniumPluginVersion>
</properties>
@@ -383,8 +383,6 @@
<systemProperties>
<appserver.base>${project.build.directory}/appserver-base</appserver.base>
<appserver.home>${project.build.directory}/appserver-base</appserver.home>
- <user.language>en</user.language>
- <user.region>US</user.region>
</systemProperties>
</container>
<configuration>
@@ -584,7 +582,7 @@
<cargo.jvm.args>
-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${cargo.debug.port}
- -Xmx512m -XX:MaxPermSize=256m -Duser.language=en
+ -Xmx512m -XX:MaxPermSize=256m
</cargo.jvm.args>
<cargo.debug.port>8000</cargo.debug.port>
<!-- wait an unusual amount of time (1hr) to allow debugging to occur -->
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArchivaAdminTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArchivaAdminTest.java
index 71bf8a844..779cdee87 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArchivaAdminTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArchivaAdminTest.java
@@ -58,9 +58,8 @@ public class ArchivaAdminTest
getSelenium().open( baseUrl );
String title = getSelenium().getTitle();
- //assertElementPresent( "adminCreateForm" );
+ // if not admin user created create one
if (isElementPresent( "adminCreateForm" ))
- //if ( title.endsWith( "Create Admin User" ) )
{
assertCreateAdmin();
String fullname = getProperty( "ADMIN_FULLNAME" );
@@ -69,10 +68,10 @@ public class ArchivaAdminTest
String password = getProperty( "ADMIN_PASSWORD" );
submitAdminData( fullname, mail, password );
assertUserLoggedIn( username );
- //submit();
- //clickLinkWithText( "Logout" );
clickLinkWithLocator( "logoutLink" );
}
+
+ // take care about repositories : internal
}
} \ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java
index a451328a1..d47ff84ce 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java
@@ -24,27 +24,32 @@ import java.io.File;
import org.apache.archiva.web.test.parent.AbstractSearchTest;
import org.testng.annotations.Test;
-@Test( groups = { "search" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+@Test( groups = { "search" }, dependsOnGroups = {"about"}, sequential = true)
public class SearchTest
extends AbstractSearchTest
{
+ @Test(alwaysRun = true)
public void testSearchNonExistingArtifact()
throws Exception
{
searchForArtifact( getProperty( "SEARCH_BAD_ARTIFACT" ) );
- assertTextPresent( "No results found" );
+ //assertTextPresent( "No results found" );
+ assertElementPresent( "//span[@class=\'errorMessage\']" );
}
// TODO: make search tests more robust especially when comparing/asserting number of hits
+ @Test(alwaysRun = true)
public void testSearchExistingArtifact()
{
searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
- assertTextPresent( "Results" );
- assertTextPresent( "Hits: 1 to 1 of 1" );
+ //assertTextPresent( "Results" );
+ assertElementPresent( "resultsBox" );
+ assertTextPresent( "1 to 1 of 1" );
assertLinkPresent( "test" );
}
+ @Test(alwaysRun = true)
public void testViewSearchedArtifact()
{
searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
@@ -54,7 +59,8 @@ public class SearchTest
clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
assertPage( "Apache Archiva \\ Browse Repository" );
}
-
+
+ @Test(alwaysRun = true)
public void testSearchWithMultipleKeywords()
{
String groupId = getProperty( "ADD_REMOVE_GROUPID" );
@@ -79,18 +85,21 @@ public class SearchTest
assertTextPresent( "No results found" );
}
+ @Test(alwaysRun = true)
public void testSearchNonExistingArtifactInAdvancedSearch()
{
searchForArtifactAdvancedSearch( null, getProperty( "SEARCH_BAD_ARTIFACT" ), null, null, null, null );
assertTextPresent( "No results found" );
}
+ @Test(alwaysRun = true)
public void testSearchNoSearchCriteriaSpecifiedInAdvancedSearch()
{
searchForArtifactAdvancedSearch( null, null, null, null, null, null );
assertTextPresent( "Advanced Search - At least one search criteria must be provided." );
}
+ @Test(alwaysRun = true)
public void testSearchExistingArtifactUsingAdvancedSearchArtifactId()
{
searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null,
@@ -100,6 +109,7 @@ public class SearchTest
assertLinkPresent( "test" );
}
+ @Test(alwaysRun = true)
public void testSearchExistingArtifactUsingAdvancedSearchGroupId()
{
searchForArtifactAdvancedSearch( getProperty( "GROUPID" ), null, null, getProperty( "REPOSITORYID" ), null,
@@ -109,6 +119,7 @@ public class SearchTest
assertLinkPresent( "test" );
}
+ @Test(alwaysRun = true)
public void testSearchExistingArtifactAllCriteriaSpecifiedInAdvancedSearch()
{
searchForArtifactAdvancedSearch( getProperty( "GROUPID" ), getProperty( "ARTIFACT_ARTIFACTID" ) , getProperty( "ARTIFACT_VERSION" ),
@@ -118,6 +129,7 @@ public class SearchTest
assertLinkPresent( "test" );
}
+ @Test(alwaysRun = true)
public void testSearchExistingArtifactUsingAdvancedSearchNotInRepository()
{
searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, "snapshots", null, null );
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
index 8cef498e9..6893ed036 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
@@ -103,7 +103,6 @@ public abstract class AbstractArchivaTest
public void goToLoginPage()
{
getSelenium().open( baseUrl );
- //clickLinkWithText( "Login" );
clickLinkWithLocator( "loginLink" );
assertLoginPage();
}
@@ -270,7 +269,7 @@ public abstract class AbstractArchivaTest
public void login( String username, String password, boolean valid, String assertReturnPage )
{
- if ( isLinkPresent( "Login" ) )
+ if ( isElementPresent( "loginLink" ) )
{
goToLoginPage();
@@ -302,8 +301,8 @@ public abstract class AbstractArchivaTest
{
checkField( "rememberMe" );
}
- clickButtonWithValue( "Login" );
-
+ //clickButtonWithValue( "Login" );
+ clickButtonWithLocator( "loginSubmit" );
if ( validUsernamePassword )
{
assertUserLoggedIn( username );
@@ -470,9 +469,14 @@ public abstract class AbstractArchivaTest
clickButtonWithValue( "Save" );
}
+ public void goToHomePage()
+ {
+ getSelenium().open( "");
+ }
// Upload Artifact
public void goToAddArtifactPage()
{
+ // must be logged as admin
getSelenium().open( "/archiva/upload.action" );
assertAddArtifactPage();
}
@@ -504,6 +508,7 @@ public abstract class AbstractArchivaTest
public void addArtifact( String groupId, String artifactId, String version, String packaging, boolean generatePom,
String artifactFilePath, String repositoryId )
{
+ login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
goToAddArtifactPage();
setFieldValue( "groupId", groupId );
setFieldValue( "artifactId", artifactId );
@@ -534,9 +539,10 @@ public abstract class AbstractArchivaTest
}
setFieldValue( "artifact", path );
- selectValue( "repositoryId", repositoryId );
+ selectValue( "upload_repositoryId", repositoryId );
- clickButtonWithValue( "Submit" );
+ //clickButtonWithValue( "Submit" );
+ clickButtonWithLocator( "uploadSubmit" );
}
public void goToRepositoriesPage()
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java
index 1d3bf8071..4383efce4 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java
@@ -25,12 +25,15 @@ public abstract class AbstractSearchTest
// Search
public void goToSearchPage()
{
- if ( !"Apache Archiva \\ Quick Search".equals( getTitle() ) )
+ goToHomePage();
+ //if ( !"Apache Archiva \\ Quick Search".equals( getTitle() ) )
+ if ( isElementPresent( "quickSearchBox" ) )
{
- clickLinkWithText( "Search" );
+ //clickLinkWithText( "Search" );
+ clickLinkWithLocator( "menuSearchLink" );
getSelenium().waitForPageToLoad( maxWaitTimeInMs );
-
- assertPage( "Apache Archiva \\ Quick Search" );
+ assertElementPresent( "quickSearchSubmit" );
+ //assertPage( "Apache Archiva \\ Quick Search" );
}
}
@@ -38,7 +41,7 @@ public abstract class AbstractSearchTest
{
assertPage( "Apache Archiva \\ Quick Search" );
assertTextPresent( "Search for" );
- assertElementPresent( "quickSearch_q" );
+ assertElementPresent( "quickSearchSubmit" );
assertButtonWithValuePresent( "Search" );
// assertLinkPresent( "Advanced Search" );
assertTextPresent( "Enter your search terms. A variety of data will be searched for your keywords." );
@@ -50,11 +53,12 @@ public abstract class AbstractSearchTest
goToSearchPage();
getSelenium().type( "dom=document.forms[1].elements[0]", artifactId );
- clickButtonWithValue( "Search" );
+ //clickButtonWithValue( "Search" );
+ clickButtonWithLocator( "quickSearchSubmit" );
}
- public void searchForArtifactAdvancedSearch( String groupId, String artifactId, String version,
- String repositoryId, String className, String rowCount )
+ public void searchForArtifactAdvancedSearch( String groupId, String artifactId, String version, String repositoryId,
+ String className, String rowCount )
{
goToSearchPage();
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java
index f5e5a4e72..c30fba72f 100644
--- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java
+++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java
@@ -72,8 +72,7 @@ public abstract class AbstractSeleniumTest
if ( getSelenium() == null )
{
- DefaultSelenium s =
- new DefaultSelenium( seleniumHost, seleniumPort, browser, baseUrl );
+ DefaultSelenium s = new DefaultSelenium( seleniumHost, seleniumPort, browser, baseUrl );
s.start();
s.setTimeout( maxWaitTimeInMs );
selenium.set( s );
@@ -255,6 +254,7 @@ public abstract class AbstractSeleniumTest
getSelenium().select( locator, "label=" + value );
}
+
public void assertOptionPresent( String selectField, String[] options )
{
assertElementPresent( selectField );
@@ -371,6 +371,21 @@ public abstract class AbstractSeleniumTest
}
}
+ public void clickButtonWithLocator( String locator )
+ {
+ clickButtonWithLocator( locator, true );
+ }
+
+ public void clickButtonWithLocator( String locator, boolean wait )
+ {
+ assertElementPresent( locator );
+ getSelenium().click( locator );
+ if ( wait )
+ {
+ waitPage();
+ }
+ }
+
public void setFieldValues( Map<String, String> fieldMap )
{
Map.Entry<String, String> entry;