From 8cfd3806cce2f02763969ba35994fcac0eb92435 Mon Sep 17 00:00:00 2001 From: "Jevica Arianne B. Zurbano" Date: Sun, 4 Jul 2010 11:27:10 +0000 Subject: [PATCH] [MRM-1394] - Replace the use of clickLinkWithText() with getSelenium().open() for accessing navigation menu pages merge -r 960310:960311 from 1.3.x branch git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@960322 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/web/test/AuditLogsReportTest.java | 4 +- .../apache/archiva/web/test/BrowseTest.java | 1 + .../web/test/RepositoryScanningTest.java | 46 ++++++++++++------- .../web/test/VirtualRepositoryTest.java | 3 +- .../web/test/parent/AbstractArchivaTest.java | 14 +++--- .../AbstractArtifactManagementTest.java | 6 +-- .../parent/AbstractArtifactReportsTest.java | 4 +- .../web/test/parent/AbstractBrowseTest.java | 4 +- .../test/parent/AbstractRepositoryTest.java | 4 +- 9 files changed, 50 insertions(+), 36 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java index a99c44325..5754a2347 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java @@ -28,7 +28,7 @@ public class AuditLogsReportTest { private void goToAuditLogReports() { - clickLinkWithText( "Audit Log Report" ); + getSelenium().open( "/archiva/report/queryAuditLogReport.action" ); } private void assertAuditLogsReportPage() @@ -188,4 +188,4 @@ public class AuditLogsReportTest assertTextPresent( expectedArtifact ); assertTextPresent( repositoryId ); } -} \ No newline at end of file +} diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java index c5fde87df..52af8a375 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java @@ -50,6 +50,7 @@ public class BrowseTest assertBrowsePage(); } + @Test( dependsOnMethods = { "testAddArtifactValidValues" } ) public void testClickArtifactFromBrowse() { goToBrowsePage(); diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java index 64559dec2..82ff698f2 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java @@ -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." ); } @@ -55,7 +55,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" ), "" ); } @@ -63,7 +63,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." ); } @@ -71,7 +71,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." ); } @@ -80,7 +80,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" ); } @@ -88,7 +88,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" ), "" ); } @@ -96,7 +96,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." ); } @@ -105,7 +105,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." ); } @@ -114,7 +114,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" ); } @@ -122,7 +122,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" ), "" ); } @@ -131,7 +131,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." ); } @@ -140,7 +140,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." ); } @@ -149,7 +149,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" ); } @@ -157,7 +157,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" ), "" ); } @@ -184,5 +184,17 @@ 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 ); + } -} \ No newline at end of file + private void clickDeleteIcon( String pattern ) + { + String xPath = "//preceding::td/code[contains(text(),'" + pattern + "')]//following::td/a/img"; + clickLinkWithLocator( xPath ); + } + +} diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java index 7054c495e..40a118220 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java @@ -51,6 +51,7 @@ public class VirtualRepositoryTest @Test( dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } ) public void testDeleteRepositoryOfRepositoryGroup() { + goToRepositoryGroupsPage(); deleteRepositoryInRepositoryGroups(); assertTextPresent( "Repository Groups" ); assertTextNotPresent( "No Repository Groups Defined." ); @@ -65,4 +66,4 @@ public class VirtualRepositoryTest assertTextPresent( "No Repository Groups Defined." ); } -} \ No newline at end of file +} 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 af29cadcb..815895875 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 @@ -147,7 +147,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 boolean valid ) { // login( getAdminUsername() , getAdminPassword() ); - clickLinkWithText( "User Management" ); + getSelenium().open( "/archiva/security/userlist.action" ); clickButtonWithValue( "Create New User" ); assertCreateUserPage(); setFieldValue( "user.username", userName ); @@ -418,7 +418,7 @@ public abstract class AbstractArchivaTest // Find Artifact public void goToFindArtifactPage() { - clickLinkWithText( "Find Artifact" ); + getSelenium().open( "/archiva/findArtifact.action" ); assertFindArtifactPage(); } @@ -435,7 +435,7 @@ public abstract class AbstractArchivaTest // Appearance public void goToAppearancePage() { - clickLinkWithText( "Appearance" ); + getSelenium().open( "/archiva/admin/configureAppearance.action" ); assertAppearancePage(); } @@ -462,7 +462,7 @@ public abstract class AbstractArchivaTest // Upload Artifact public void goToAddArtifactPage() { - clickLinkWithText( "Upload Artifact" ); + getSelenium().open( "/archiva/upload.action" ); assertAddArtifactPage(); } @@ -532,7 +532,7 @@ public abstract class AbstractArchivaTest { if ( !getTitle().equals( "Apache Archiva \\ Administration - Repositories" ) ) { - clickLinkWithText( "Repositories" ); + getSelenium().open( "/archiva/admin/repositories.action" ); } assertRepositoriesPage(); } @@ -570,4 +570,4 @@ public abstract class AbstractArchivaTest assertLinkNotPresent( "Logout" ); assertLinkPresent( "Login" ); } -} \ No newline at end of file +} diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java index e73e08009..c82ac3175 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java @@ -61,7 +61,7 @@ public abstract class AbstractArtifactManagementTest public void goToDeleteArtifactPage() { login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) ); - clickLinkWithText( "Delete Artifact" ); + getSelenium().open( "/archiva/deleteArtifact.action" ); assertDeleteArtifactPage(); } @@ -93,7 +93,7 @@ public abstract class AbstractArtifactManagementTest // Legacy Support public void goToLegacySupportPage() { - clickLinkWithText( "Legacy Support" ); + getSelenium().open( "/archiva/admin/legacyArtifactPath.action" ); assertLegacySupportPage(); } @@ -130,4 +130,4 @@ public abstract class AbstractArtifactManagementTest assertElementPresent( arrayelement ); assertButtonWithValuePresent( "Add Legacy Artifact Path" ); } -} \ No newline at end of file +} diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactReportsTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactReportsTest.java index ce5ad2aa0..e026f7805 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactReportsTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactReportsTest.java @@ -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 +} diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractBrowseTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractBrowseTest.java index 3de6c4fd6..2b4fc1194 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractBrowseTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractBrowseTest.java @@ -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 +} diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java index 2ac76bd81..2dce7f1ee 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java @@ -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(); } @@ -383,4 +383,4 @@ public abstract class AbstractRepositoryTest assertTextPresent( "Database - Unprocessed Artifacts Scanning" ); assertTextPresent( "Database - Artifact Cleanup Scanning" ); } -} \ No newline at end of file +}