diff options
author | Maria Odea B. Ching <oching@apache.org> | 2009-11-16 08:33:59 +0000 |
---|---|---|
committer | Maria Odea B. Ching <oching@apache.org> | 2009-11-16 08:33:59 +0000 |
commit | 3724f9749c820f3272937544026f450ef12677f9 (patch) | |
tree | ec8ab6c10bdcd4bd4c5a3a92e8b00b2904d49feb /archiva-modules | |
parent | 4abf4521ef700a806b31103f6a626462a0fd4c3e (diff) | |
download | archiva-3724f9749c820f3272937544026f450ef12677f9.tar.gz archiva-3724f9749c820f3272937544026f450ef12677f9.zip |
[MRM-1277] Create Selenium test for advanced search feature
o added webapp tests for searching non existing artifacts and when no search criteria is specified in advanced search
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@880666 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules')
2 files changed, 84 insertions, 11 deletions
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 553216561..08a748a49 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 @@ -54,6 +54,24 @@ public class SearchTest assertPage( "Apache Archiva \\ Browse Repository" ); } - + public void testSearchNonExistingArtifactInAdvancedSearch() + { + searchForArtifactAdvancedSearch( null, getProperty( "SEARCH_BAD_ARTIFACT"), null, null, null, null ); + assertTextPresent( "No results found" ); + } + + public void testSearchNoSearchCriteriaSpecifiedInAdvancedSearch() + { + searchForArtifactAdvancedSearch( null, null, null, null, null, null ); + assertTextPresent( "Advanced Search - At least one search criteria must be provided." ); + } + /* public void testSearchExistingArtifactUsingAdvancedSearchArtifactId() + { + searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, null, null, null ); + assertTextPresent( "Results" ); + assertTextPresent( "Hits: 1 to 1 of 1" ); + assertLinkPresent( "test" ); + }*/ } + 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 f31f5dc7e..410ec14ab 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,8 +25,13 @@ public abstract class AbstractSearchTest //Search public void goToSearchPage() { - clickLinkWithText( "Search" ); - assertSearchPage(); + if ( !"Apache Archiva \\ Quick Search".equals( getSelenium().getTitle() ) ) + { + clickLinkWithText( "Search" ); + getSelenium().waitForPageToLoad( maxWaitTimeInMs ); + + assertPage( "Apache Archiva \\ Quick Search" ); + } } public void assertSearchPage() @@ -42,16 +47,66 @@ public abstract class AbstractSearchTest public void searchForArtifact( String artifactId ) { - if ( !"Apache Archiva \\ Quick Search".equals( getSelenium().getTitle() ) ) - { - clickLinkWithText( "Search" ); - - getSelenium().waitForPageToLoad( maxWaitTimeInMs ); - - assertPage( "Apache Archiva \\ Quick Search" ); - } + goToSearchPage(); getSelenium().type( "dom=document.forms[1].elements[0]", artifactId ); clickButtonWithValue( "Search" ); } + + public void searchForArtifactAdvancedSearch( String groupId, String artifactId, String version, String repositoryId, + String className, String rowCount ) + { + goToSearchPage(); + + clickLinkWithXPath( "//div[@id='contentArea']/div[1]/a[1]/strong", false ); + assertElementPresent( "filteredSearch_searchField" ); + assertElementPresent( "filteredSearch_repositoryId" ); + + if ( groupId != null ) + { + selectValue( "filteredSearch_searchField", "Group ID" ); + clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false ); + + assertElementPresent( "groupId" ); + setFieldValue( "groupId", groupId ); + } + + if ( artifactId != null ) + { + selectValue( "filteredSearch_searchField", "Artifact ID" ); + clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false ); + + assertElementPresent( "artifactId" ); + setFieldValue( "artifactId", artifactId ); + } + + if ( version != null ) + { + selectValue( "filteredSearch_searchField", "Version" ); + clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false ); + + assertElementPresent( "version" ); + setFieldValue( "version", version ); + } + + if ( className != null ) + { + selectValue( "filteredSearch_searchField", "Class/Package Name" ); + clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false ); + + assertElementPresent( "className" ); + setFieldValue( "className", className ); + } + + if ( rowCount != null ) + { + selectValue( "filteredSearch_searchField", "Row Count" ); + clickLinkWithLocator( "//a[@id='filteredSearch_']/img", false ); + + assertElementPresent( "rowCount" ); + setFieldValue( "rowCount", rowCount ); + } + + clickSubmitWithLocator( "filteredSearch_0" ); + } }
\ No newline at end of file |