]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1394] - Replace the use of clickLinkWithText() with getSelenium().open() for...
authorJevica Arianne B. Zurbano <jzurbano@apache.org>
Sun, 4 Jul 2010 09:28:02 +0000 (09:28 +0000)
committerJevica Arianne B. Zurbano <jzurbano@apache.org>
Sun, 4 Jul 2010 09:28:02 +0000 (09:28 +0000)
* replaced clickLinkWithText() with getSelenium().open()
* added clickAddIcon() and clickDeleteIcon() to be used instead of clickLinkWithXPath() in RepositoryScanningTest
* added dependsOnMethods in testClickArtifactFromBrowse of BrowseTest

git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-1.3.x@960311 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactReportsTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractBrowseTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java

index 1a1d6314b9e654fa6dd8ae4826b06a13de490957..8199ef2249d4676fc67e6a2adf9f8d1233a5acb6 100644 (file)
@@ -28,7 +28,7 @@ public class AuditLogsReportTest
 {
     private void goToAuditLogReports()
     {
-        clickLinkWithText( "Audit Log Report" );        
+        getSelenium().open( "/archiva/report/queryAuditLogReport.action" );
     }
     
     private void assertAuditLogsReportPage()
index 7d9c27f94c6547c7e90c9f862f348a6ab278a978..2f73cecb8df904cd6d0c62d791825971e2f2f711 100644 (file)
@@ -36,6 +36,7 @@ public class BrowseTest
                assertBrowsePage();
        }
        
+       @Test( dependsOnMethods = { "testAddArtifactValidValues" } )
        public void testClickArtifactFromBrowse()
        {
                goToBrowsePage();
index 6d00d1a3272b64710b1c445a9da985f85bc6bdef..d5b369b2d2ea26c3bca925192fb39455f9fdadce 100644 (file)
@@ -30,7 +30,7 @@ public class RepositoryScanningTest
        public void testAddArtifactFileType_NullValue()
        {
                goToRepositoryScanningPage();
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" );
+               clickAddIcon( "newpattern_0" );
                assertTextPresent( "Unable to process blank pattern." );
        }
        
@@ -38,7 +38,7 @@ public class RepositoryScanningTest
        public void testAddArtifactFileType()
        {
                setFieldValue( "newpattern_0" , "**/*.dll" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" );
+               clickAddIcon( "newpattern_0" );
                Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "**/*.dll" );
        }
        
@@ -46,7 +46,7 @@ public class RepositoryScanningTest
        public void testAddArtifactFileType_ExistingValue()
        {
                setFieldValue( "newpattern_0" , "**/*.zip" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[15]/td[2]/a/img" );
+               clickAddIcon( "newpattern_0" );
                Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.zip\" to filetype artifacts as it already exists." );
        }
        
@@ -54,7 +54,7 @@ public class RepositoryScanningTest
        public void testDeleteArtifactFileType()
        {
                Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "**/*.dll" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" );
+               clickDeleteIcon( "**/*.dll" );
                Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "" );
        }
        
@@ -62,7 +62,7 @@ public class RepositoryScanningTest
        public void testAddAutoRemove_NullValue()
        {
                setFieldValue( "newpattern_1" , "" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
+               clickAddIcon( "newpattern_1" );
                assertTextPresent( "Unable to process blank pattern." );
        }
        
@@ -70,7 +70,7 @@ public class RepositoryScanningTest
        public void testAddAutoRemove_ExistingValue()
        {
                setFieldValue( "newpattern_1" , "**/*-" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
+               clickAddIcon( "newpattern_1" );
                Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." );
        }
        
@@ -78,7 +78,7 @@ public class RepositoryScanningTest
        public void testAddAutoRemove()
        {
                setFieldValue( "newpattern_1" , "**/*.test" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
+               clickAddIcon( "newpattern_1" );
                Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "**/*.test" );
        }
        
@@ -86,7 +86,7 @@ public class RepositoryScanningTest
        public void testDeleteAutoRemove()
        {
                Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "**/*.test" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
+               clickDeleteIcon( "**/*.test" );
                Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "" );
        }
        
@@ -94,7 +94,7 @@ public class RepositoryScanningTest
        public void testAddIgnoredArtifacts_NullValue()
        {
                setFieldValue( "newpattern_2" , "" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
+               clickAddIcon( "newpattern_2" );
                Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." );
        }
        
@@ -102,7 +102,7 @@ public class RepositoryScanningTest
        public void testAddIgnoredArtifacts_ExistingValue()
        {
                setFieldValue( "newpattern_2" , "**/*.sh" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
+               clickAddIcon( "newpattern_2" );
                Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." );
        }
        
@@ -110,7 +110,7 @@ public class RepositoryScanningTest
        public void testAddIgnoredArtifacts()
        {
                setFieldValue( "newpattern_2" , "**/*.log" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
+               clickAddIcon( "newpattern_2" );
                Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "**/*.log" );
        }
        
@@ -118,7 +118,7 @@ public class RepositoryScanningTest
        public void testDeleteIgnoredArtifacts()
        {
                Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "**/*.log" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
+               clickDeleteIcon( "**/*.log" );
                Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "" );
         }
        
@@ -127,7 +127,7 @@ public class RepositoryScanningTest
        public void testAddIndexableContent_NullValue()
        {
                setFieldValue( "newpattern_3" , "" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
+               clickAddIcon( "newpattern_3" );
                Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." );
        }
        
@@ -135,7 +135,7 @@ public class RepositoryScanningTest
        public void testAddIndexableContent_ExistingValue()
        {
                setFieldValue( "newpattern_3" , "**/*.xml" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
+               clickAddIcon( "newpattern_3" );
                Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." );
        }
        
@@ -143,7 +143,7 @@ public class RepositoryScanningTest
        public void testAddIndexableContent()
        {
                setFieldValue( "newpattern_3" , "**/*.html" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
+               clickAddIcon( "newpattern_3" );
                Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "**/*.html" );
        }
        
@@ -151,7 +151,7 @@ public class RepositoryScanningTest
        public void testDeleteIndexableContent()
        {
                Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "**/*.html" );
-               clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
+               clickDeleteIcon( "**/*.html" );
                Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "" );
        }
        
@@ -180,4 +180,16 @@ public class RepositoryScanningTest
                assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
        }
        
+       private void clickAddIcon( String fieldId )
+       {
+               String xPath = "//preceding::td/input[@id='" + fieldId + "']//following::td/a/img";
+               clickLinkWithLocator( xPath );
+       }
+       
+       private void clickDeleteIcon( String pattern )
+       {
+               String xPath = "//preceding::td/code[contains(text(),'" + pattern + "')]//following::td/a/img";
+               clickLinkWithLocator( xPath );
+       }
+       
 }
index ee49694d38b74b1f43c090637a0e99d51da2569f..0c7df55d1a7962c02db9d2ddce7e2430800f0b9a 100644 (file)
@@ -29,7 +29,7 @@ public class RepositoryTest
        public void testAddManagedRepoValidValues()
        {
                goToRepositoriesPage();
-               clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRepository.action']" );
+               getSelenium().open( "/archiva/admin/addRepository.action" );
                addManagedRepository( "managedrepo1", "Managed Repository Sample 1" , getRepositoryDir() + "repository/" , "", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
                clickButtonWithValue( "Save" );
                assertTextPresent( "Managed Repository Sample 1" );             
@@ -40,7 +40,7 @@ public class RepositoryTest
        public void testAddManagedRepoInvalidValues()
        {                               
                goToRepositoriesPage();
-           clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRepository.action']" );  
+               getSelenium().open( "/archiva/admin/addRepository.action" );    ;       
                addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" );
                assertTextPresent( "You must enter a repository identifier." );
                assertTextPresent( "You must enter a repository name." );
@@ -105,7 +105,7 @@ public class RepositoryTest
        @Test(dependsOnMethods = { "testAddRemoteRepoValidValues" } )
        public void testAddRemoteRepoNullValues()
        {               
-           clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRemoteRepository.action']" );
+           getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
                addRemoteRepository( "" , "" , "" , "" , "" , "" , "Maven 2.x Repository" );
                assertTextPresent( "You must enter a repository identifier." );
                assertTextPresent( "You must enter a repository name." );
@@ -136,7 +136,7 @@ public class RepositoryTest
        @Test(dependsOnMethods = { "testDeleteManageRepo" } )
        public void testAddRemoteRepoValidValues()
        {               
-               clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRemoteRepository.action']" );
+               getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
                addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
                assertTextPresent( "Remote Repository Sample" );
        }
index befbea9548b475ca91387098e973b3aff223ed43..158baf1349745426d606bc2ff7bc87dd62356a48 100644 (file)
@@ -53,6 +53,7 @@ public class VirtualRepositoryTest
        @Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } )
        public void testDeleteRepositoryOfRepositoryGroup()
        {
+               goToRepositoryGroupsPage();
                deleteRepositoryInRepositoryGroups();
                assertTextPresent( "Repository Groups" );
                assertTextNotPresent( "No Repository Groups Defined." );
index 642949e1a93866a3dd3ba3f6370df5f6a6b2df6c..3a2131dcbadda4d65285d5f2eb2eb1688530ce2d 100644 (file)
@@ -146,7 +146,7 @@ public abstract class AbstractArchivaTest
     //User Management
        public void goToUserManagementPage()
        {
-               clickLinkWithText( "User Management" );
+               getSelenium().open( "/archiva/security/userlist.action" );
                assertUserManagementPage();
        }
        
@@ -216,7 +216,7 @@ public abstract class AbstractArchivaTest
        private void createUser( String userName, String fullName, String emailAd, String password, String confirmPassword, boolean valid ) 
        {
                //login( getAdminUsername() , getAdminPassword() );
-               clickLinkWithText( "User Management" );
+               getSelenium().open( "/archiva/security/userlist.action" );
                clickButtonWithValue( "Create New User" );
                assertCreateUserPage();
         setFieldValue( "user.username", userName );
@@ -409,7 +409,7 @@ public abstract class AbstractArchivaTest
        //Find Artifact
        public void goToFindArtifactPage()
        {
-               clickLinkWithText( "Find Artifact" );
+               getSelenium().open( "/archiva/findArtifact.action" );
                assertFindArtifactPage();
        }
        
@@ -426,7 +426,7 @@ public abstract class AbstractArchivaTest
        //Appearance
        public void goToAppearancePage()
        {
-               clickLinkWithText( "Appearance" );
+               getSelenium().open( "/archiva/admin/configureAppearance.action" );
                assertAppearancePage();
        }
        
@@ -452,7 +452,7 @@ public abstract class AbstractArchivaTest
        // Upload Artifact
     public void goToAddArtifactPage()
     {
-        clickLinkWithText( "Upload Artifact" );
+        getSelenium().open( "/archiva/upload.action" );
         assertAddArtifactPage();
     }
 
@@ -522,7 +522,7 @@ public abstract class AbstractArchivaTest
     {
         if( !getTitle().equals( "Apache Archiva \\ Administration - Repositories" ) )
         {
-            clickLinkWithText( "Repositories" );
+            getSelenium().open( "/archiva/admin/repositories.action" );
         }
        assertRepositoriesPage();
     }
index 04f5242a757405f26180c4392cc2eb3a7a3ac7a3..433c040149fa2cd78b2ec0d9bde71e446d514e79 100644 (file)
@@ -42,7 +42,7 @@ public abstract class AbstractArtifactManagementTest
        public void goToDeleteArtifactPage()
        {
         login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
-               clickLinkWithText( "Delete Artifact" );
+               getSelenium().open( "/archiva/deleteArtifact.action" );
                assertDeleteArtifactPage();
        }
                
@@ -74,7 +74,7 @@ public abstract class AbstractArtifactManagementTest
        // Legacy Support
        public void goToLegacySupportPage()
        {
-               clickLinkWithText( "Legacy Support" );
+               getSelenium().open( "/archiva/admin/legacyArtifactPath.action" );
                assertLegacySupportPage();
        }
        
index fe41f490b4edfcd536074a1651e3b38853d3a995..19a6c7d131bd6ca458949635fd2ab0dea6eaa477 100644 (file)
@@ -26,7 +26,7 @@ public abstract class AbstractArtifactReportsTest
        //Reports
        public void goToReportsPage()
        {
-               clickLinkWithText( "Reports" );
+               getSelenium().open( "/archiva/report/pickReport.action" );
                assertReportsPage();
        }
        
@@ -77,4 +77,4 @@ public abstract class AbstractArtifactReportsTest
                clickButtonWithValue( "View Statistics" );
        }
 
-}
\ No newline at end of file
+}
index 8fe485fc4e340b6f09d19100951910d691b79ced..01ea9c066727a90de385e9eb06e5cd8c20d51b01 100644 (file)
@@ -26,7 +26,7 @@ public abstract class AbstractBrowseTest
        //Browse
        public void goToBrowsePage()
        {
-               clickLinkWithText( "Browse" );
+               getSelenium().open( "/archiva/browse" );
                assertBrowsePage();
        }
 
@@ -37,4 +37,4 @@ public abstract class AbstractBrowseTest
                assertTextPresent( "Groups" );
        }
 
-}
\ No newline at end of file
+}
index 6c8e66209cf03db608daa87b211f1a0df358ec49..7595a335fffc1c4e1293a48716346cbc4597c7ae 100644 (file)
@@ -30,7 +30,7 @@ public abstract class AbstractRepositoryTest
        {
            if( !getTitle().equals( "Apache Archiva \\ Administration - Repository Groups" ) )
            {
-               clickLinkWithText( "Repository Groups" );
+               getSelenium().open( "/archiva/admin/repositoryGroups.action" );
            }
                assertRepositoryGroupsPage();
        }
@@ -67,7 +67,7 @@ public abstract class AbstractRepositoryTest
                assertPage( "Apache Archiva \\ Admin: Delete Repository Group" );
                assertTextPresent( "WARNING: This operation can not be undone." );
                assertTextPresent( "Are you sure you want to delete the following repository group?" );
-               assertTextPresent( "ID: " + repositoryName );
+               assertElementPresent( "//preceding::td[text()='ID:']//following::td/code[text()='" + repositoryName + "']" );
                assertButtonWithValuePresent( "Confirm" );
                assertButtonWithValuePresent( "Cancel" );
        }