From 3a06b4940779d9a26b59b0db04d621495820e468 Mon Sep 17 00:00:00 2001 From: Wendy Smoak Date: Thu, 18 Jun 2009 04:06:33 +0000 Subject: [PATCH] [MRM-1164] Add Selenium tests for virtual repositories and capture screen shots of failing tests. Submitted by: Marecor Baclay git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@785892 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/resources/testng.properties | 20 +- .../src/test/testng/config/testng.xml | 2 + .../web/test/VirtualRepositoryTest.java | 54 +++ .../test/parent/AbstractRepositoryTest.java | 318 ++++++++++++++++++ .../web/test/parent/AbstractSeleniumTest.java | 176 +++++++++- 5 files changed, 552 insertions(+), 18 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java create mode 100644 archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties b/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties index 993e07d5d..bc6dafd71 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties @@ -76,5 +76,23 @@ ARTIFACTID1=delete VERSION1=1.0 PACKAGING1=jar ARTIFACTFILEPATH1=test -# /home/cora/Documents/MAESTRO/installers/maestro-2.1.1/project-server/core/activation-1.1.jar REPOSITORYID1=internal + +# REPOSITORIES +# Manage Repositories +MANAGED_IDENTIFIER=testing1 +MANAGED_NAME=Testing Managed Repository +MANAGED_DIRECTORY= +MANAGED_INDEX_DIRECTORY= +MANAGED_TYPE= +MANAGED_CRON= +MANAGED_REPOPURGE_DAYSOLDERTHAN= +MANAGED_REPOPURGE_RETENTIONCOUNT= + +# Network Proxies +NETWORKPROXY_IDENTIFIER=networkproxytest +NETWORKPROXY_PROTOCOL=http +NETWORKPROXY_HOSTNAME= +NETWORKPROXY_PORT=8080 +NETWORKPROXY_USERNAME=admin +NETWORKPROXY_PASSWORD=admin123 diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml index f8bf37259..29b20155f 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml @@ -39,6 +39,8 @@ under the License. + + 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 new file mode 100644 index 000000000..cecd7e44c --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java @@ -0,0 +1,54 @@ +package org.apache.archiva.web.test; + +import org.apache.archiva.web.test.parent.AbstractRepositoryTest; +import org.testng.annotations.Test; + +@Test( groups = { "virtualrepository" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) +public class VirtualRepositoryTest + extends AbstractRepositoryTest +{ + public void testAddRepositoryNullValue() + { + addRepositoryGroup( " " ); + assertTextPresent( "Identifier field is required." ); + } + + @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } ) + public void testAddRepositoryValidValue() + { + addRepositoryGroup( "testing" ); + //assertAddedRepositoryLink( "testing" ); + assertTextPresent( "testing" ); + } + + //@Test(dependsOnMethods = { "testAddRepositoryValidValue" } ) + public void testAddRepositoryToRepositoryGroup() + { + addRepositoryToRepositoryGroup( "testing", "internal" ); + assertTextPresent( "internal" ); + //clickLinkWithXPath( "/html/body/div[4]/div/div/div[2]/div/div/p[2]/a" ); + //getSelenium().goBack(); + } + + @Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } ) + public void testDeleteRepositoryOfRepositoryGroup() + { + deleteRepositoryInRepositoryGroups(); + assertTextPresent( "Repository Groups" ); + assertTextNotPresent( "No Repository Groups Defined." ); + } + + @Test(dependsOnMethods = { "testDeleteRepositoryOfRepositoryGroup" } ) + public void testDeleteRepositoryGroup() + { + deleteRepositoryGroup( "testing" ); + assertTextPresent( "No Repository Groups Defined." ); + } + + /*@Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } ) + public void testCheckRepositoryGroup() + { + clickLinkWithXPath( "/html/body/div[4]/div/div/div[2]/div/div/p[2]/a" ); + getSelenium().goBack(); + }*/ +} 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 new file mode 100644 index 000000000..7bd94dc17 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java @@ -0,0 +1,318 @@ +package org.apache.archiva.web.test.parent; + +public abstract class AbstractRepositoryTest + extends AbstractArchivaTest +{ + // Repository Groups + public void goToRepositoryGroupsPage() + { + clickLinkWithText( "Repository Groups" ); + assertRepositoryGroupsPage(); + } + + public void assertRepositoryGroupsPage() + { + assertPage( "Apache Archiva \\ Administration - Repository Groups" ); + assertTextPresent( "Administration - Repository Groups" ); + assertTextPresent( "Identifier*:" ); + assertElementPresent( "repositoryGroup.id" ); + assertButtonWithValuePresent( "Add Group" ); + assertTextPresent( "Repository Groups" ); + } + + public void assertAddedRepositoryLink( String repositoryGroupName) + { + assertPage( "Apache Archiva \\ Administration - Repository Groups" ); + String repositoryGroupUrlValue = "repository/" + repositoryGroupName + "/"; + String baseUrlValue = "archiva"; + String repositoryGroupLink = baseUrl.replaceFirst( baseUrlValue, repositoryGroupUrlValue); + assertTextPresent( repositoryGroupLink ); + } + + public void assertAddedRepositoryToRepositoryGroups( String repositoryName) + { + assertPage( "Apache Archiva \\ Administration - Repository Groups" ); + assertTextPresent( repositoryName ); + assertTextPresent( "Archiva Managed Internal Repository" ); + assertAddedRepositoryLink( repositoryName ); + } + + public void assertDeleteRepositoryGroupPage( String repositoryName) + { + 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 ); + assertButtonWithValuePresent( "Confirm" ); + assertButtonWithValuePresent( "Cancel" ); + } + + public void addRepositoryGroup( String repoGroupName ) + { + goToRepositoryGroupsPage(); + setFieldValue( "repositoryGroup.id", repoGroupName ); + clickButtonWithValue( "Add Group" ); + } + + public void addRepositoryToRepositoryGroup( String repositoryGroupName, String repositoryName ) + { + goToRepositoryGroupsPage(); + String s = getSelenium().getBodyText(); + if ( s.contains( "No Repository Groups Defined." ) ) + { + setFieldValue( "repositoryGroup.id" , repositoryGroupName ); + clickButtonWithValue( "Add Group" ); + //assertAddedRepositoryLink( repositoryGroupName ); + + selectValue( "addRepositoryToGroup_repoId" , repositoryName ); + clickButtonWithValue( "Add Repository" ); + assertAddedRepositoryToRepositoryGroups( repositoryName ); + } + else + { + //assertAddedRepositoryLink( repositoryGroupName ); + selectValue( "addRepositoryToGroup_repoId" , repositoryName ); + clickButtonWithValue( "Add Repository" ); + } + } + + public void deleteRepositoryInRepositoryGroups() + { + getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" ); + } + + public void deleteRepositoryGroup( String repositoryName ) + { + //goToRepositoryGroupsPage(); + getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" ); + waitPage(); + assertDeleteRepositoryGroupPage( repositoryName ); + clickButtonWithValue( "Confirm" ); + } + + /////////////////////////////// + // proxy connectors + /////////////////////////////// + public void goToProxyConnectorsPage() + { + clickLinkWithText( "Proxy Connectors" ); + assertProxyConnectorsPage(); + } + + public void assertProxyConnectorsPage() + { + assertPage( "Apache Archiva \\ Administration - Proxy Connectors" ); + assertTextPresent( "Administration - Proxy Connectors" ); + assertTextPresent( "Repository Proxy Connectors" ); + assertTextPresent( "internal" ); + assertTextPresent( "Archiva Managed Internal Repository" ); + assertTextPresent( "Proxy Connector" ); + assertTextPresent( "Central Repository" ); + assertTextPresent( "Java.net Repository for Maven 2" ); + } + + public void assertAddProxyConnectorPage() + { + assertPage( "Apache Archiva \\ Admin: Add Proxy Connector" ); + assertTextPresent( "Admin: Add Proxy Connector" ); + String proxy = "Network Proxy*:,Managed Repository*:,Remote Repository*:,Policies:,Return error when:,On remote error:,Releases:,Snapshots:,Checksum:,Cache failures:,Properties:,No properties have been set.,Black List:,No black list patterns have been set.,White List:,No white list patterns have been set."; + String[] arrayProxy = proxy.split( "," ); + for ( String arrayproxy : arrayProxy ) + assertTextPresent( arrayproxy ); + /*String proxyElements = "addProxyConnector_connector_proxyId,addProxyConnector_connector_sourceRepoId,addProxyConnector_connector_targetRepoId,policy_propagate-errors-on-update,policy_propagate-errors,policy_releases,policy_snapshots,policy_checksum,policy_cache-failures,propertiesEntry,propertiesValue,blackListEntry,whiteListEntry"; + String[] arrayProxyElements = proxyElements.split( "," ); + for ( String arrayproxyelements : arrayProxyElements ) + assertTextPresent( arrayproxyelements );*/ + assertButtonWithValuePresent( "Add Property" ); + assertButtonWithValuePresent( "Add Pattern" ); + assertButtonWithValuePresent( "Add Proxy Connector" ); + } + + // this only fills in the values of required fields in adding Proxy Connectors + public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo ) + { + goToProxyConnectorsPage(); + clickLinkWithText( "Add" ); + assertAddProxyConnectorPage(); + selectValue( "connector.proxyId" , networkProxy ); + selectValue( "connector.sourceRepoId" , managedRepo ); + selectValue( "connector.targetRepoId" , remoteRepo ); + } + + public void deleteProxyConnector() + { + goToProxyConnectorsPage(); + clickLinkWithXPath( "//div[@id='contentArea']/div[2]/div[1]/div[2]/div[1]/a[3]/img" ); + assertPage( "Apache Archiva \\ Admin: Delete Proxy Connectors" ); + clickButtonWithValue( "Delete" ); + assertPage( "Apache Archiva \\ Administration - Proxy Connectors" ); + } + + /////////////////////////////// + // network proxies + /////////////////////////////// + public void goToNetworkProxiesPage() + { + clickLinkWithText( "Network Proxies" ); + assertNetworkProxiesPage(); + } + + public void assertNetworkProxiesPage() + { + assertPage( "Apache Archiva \\ Administration - Network Proxies" ); + assertTextPresent( "Administration - Network Proxies" ); + assertTextPresent( "Network Proxies" ); + assertLinkPresent( "Add Network Proxy" ); + } + + public void assertAddNetworkProxy() + { + assertPage( "Apache Archiva \\ Admin: Add Network Proxy" ); + assertTextPresent( "Admin: Add Network Proxy" ); + assertTextPresent( "Add network proxy:" ); + assertTextPresent( "Identifier*:" ); + assertTextPresent( "Protocol*:" ); + assertTextPresent( "Hostname*:" ); + assertTextPresent( "Port*:" ); + assertTextPresent( "Username:" ); + assertTextPresent( "Password:" ); + assertButtonWithValuePresent( "Save Network Proxy" ); + } + + public void addNetworkProxyWithAccount( String identifier, String protocol, String hostname, String port, String username, String password ) + { + goToNetworkProxiesPage(); + clickLinkWithText( "Add Network Proxy" ); + assertAddNetworkProxy(); + setFieldValue( "proxy.id" , identifier ); + setFieldValue( "proxy.protocol" , protocol ); + setFieldValue( "proxy.host" , hostname ); + setFieldValue( "proxy.port" , port ); + setFieldValue( "proxy.username" , username ); + setFieldValue( "proxy.password" , password ); + clickButtonWithValue( "Save Network Proxy" ); + } + + public void editNetworkProxies( String fieldName, String value) + { + goToNetworkProxiesPage(); + clickLinkWithText( "Edit Network Proxy" ); + setFieldValue( fieldName, value); + clickButtonWithValue( "Save Network Proxy" ); + } + + public void deleteNetworkProxy() + { + goToNetworkProxiesPage(); + clickLinkWithText( "Delete Network Proxy" ); + assertPage( "Apache Archiva \\ Admin: Delete Network Proxy" ); + clickButtonWithValue( "Delete" ); + } + + /////////////////////////////// + // repositories + /////////////////////////////// + public void goToRepositoriesPage() + { + clickLinkWithText( "Repositories" ); + assertRepositoriesPage(); + } + + public void assertRepositoriesPage() + { + assertPage( "Apache Archiva \\ Administration - Repositories" ); + assertTextPresent( "Administration - Repositories" ); + assertTextPresent( "Managed Repositories" ); + assertTextPresent( "Remote Repositories" ); + } + + // remote repositories + public void assertAddRemoteRepository() + { + assertPage( "Apache Archiva \\ Admin: Add Remote Repository" ); + String remote = "Identifier*:,Name*:,URL*:,Username:,Password:,Timeout in seconds:,Type:"; + String[] arrayRemote = remote.split( "," ); + for ( String arrayremote : arrayRemote ) + assertTextPresent( arrayremote ); + String remoteElements = "addRemoteRepository_repository_id,addRemoteRepository_repository_name,addRemoteRepository_repository_url,addRemoteRepository_repository_username,addRemoteRepository_repository_password,addRemoteRepository_repository_timeout,addRemoteRepository_repository_layout"; + String[] arrayRemoteElements = remoteElements.split( "," ); + for ( String arrayremotelement : arrayRemoteElements ) + assertElementPresent( arrayremotelement ); + } + + public void assertDeleteRemoteRepositoryPage() + { + assertPage( "Apache Archiva \\ Admin: Delete Remote Repository" ); + assertTextPresent( "Admin: Delete Remote Repository" ); + assertTextPresent( "WARNING: This operation can not be undone." ); + assertTextPresent( "Are you sure you want to delete the following remote repository?" ); + assertButtonWithValuePresent( "Confirm" ); + assertButtonWithValuePresent( "Cancel" ); + } + + public void addRemoteRepository( String identifier, String name, String url, String username, String password, String timeout, String type ) + { + goToRepositoriesPage(); + clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/a" ); + assertAddRemoteRepository(); + setFieldValue( "addRemoteRepository_repository_id" , identifier ); + setFieldValue( "addRemoteRepository_repository_name" , name ); + setFieldValue( "addRemoteRepository_repository_url" , url ); + setFieldValue( "addRemoteRepository_repository_username" , username ); + setFieldValue( "addRemoteRepository_repository_password" , password ); + setFieldValue( "addRemoteRepository_repository_timeout" , timeout ); + selectValue( "addRemoteRepository_repository_layout" , type ); + clickButtonWithValue( "Add Repository" ); + } + + public void deleteRemoteRepository() + { + goToRepositoriesPage(); + clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" ); + assertDeleteRemoteRepositoryPage(); + clickButtonWithValue( "Confirm" ); + } + + public void editRemoteRepository( String fieldName, String value) + { + goToRepositoriesPage(); + clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" ); + setFieldValue( fieldName, value ); + clickButtonWithValue( "Update Repository" ); + } + + // managed repositories + public void addManagedRepository( String identifier, String name, String directory, String indexDirectory, String type, String cron, String daysOlder, String retentionCount ) + { + goToRepositoriesPage(); + clickLinkWithText( "Add" ); + setFieldValue( "repository.id" , identifier ); + setFieldValue( "repository.name" , name ); + setFieldValue( "repository.location" , directory ); + setFieldValue( "repository.indexDir" , indexDirectory ); + selectValue( "repository.layout", type ); + setFieldValue( "repository.refreshCronExpression" , cron ); + setFieldValue( "repository.daysOlder" , daysOlder ); + setFieldValue( "repository.retentionCount" , retentionCount ); + //TODO + clickButtonWithValue( "Add Repository" ); + } + + public void editManagedRepository( String fieldName, String value ) + { + goToRepositoriesPage(); + clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/div[1]/a[1]/img" ); + assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" ); + setFieldValue(fieldName, value); + //TODO + clickButtonWithValue( "Update Repository" ); + } + + public void deleteManagedRepository() + { + goToRepositoriesPage(); + clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/div[1]/a[2]" ); + assertPage( "Apache Archiva \\ Admin: Delete Managed Repository" ); + clickButtonWithValue( "Delete Configuration Only" ); + } +} \ 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/AbstractSeleniumTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java index f08b7428d..e263d934a 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 @@ -19,7 +19,9 @@ package org.apache.archiva.web.test.parent; * under the License. */ +import java.io.File; import java.util.Arrays; +import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -91,15 +93,43 @@ public abstract class AbstractSeleniumTest { // Auxiliar methods. This method help us and simplify test. // ******************************************************* + public void captureScreenshot() + { + Date t = new Date(); + File f = new File( "" ); + String baseDir = f.getAbsolutePath(); + String time = t.toString(); + getSelenium().windowMaximize(); + getSelenium().windowFocus(); + getSelenium().captureScreenshot( baseDir + "/target/screenshots/" + getClass() + "-" + time + ".png" ); + } + public void assertFieldValue( String fieldValue, String fieldName ) { - assertElementPresent( fieldName ); - Assert.assertEquals( fieldValue, getSelenium().getValue( fieldName ) ); + try + { + assertElementPresent( fieldName ); + Assert.assertEquals( fieldValue, getSelenium().getValue( fieldName ) ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + assertElementPresent( fieldName ); + Assert.assertEquals( fieldValue, getSelenium().getValue( fieldName ) ); + } } public void assertPage( String title ) { - Assert.assertEquals( getSelenium().getTitle(), title ); + try + { + Assert.assertEquals( getSelenium().getTitle(), title ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + Assert.assertEquals( getSelenium().getTitle(), title ); + } } public String getTitle() @@ -114,37 +144,93 @@ public abstract class AbstractSeleniumTest { public void assertTextPresent( String text ) { - Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." ); + try + { + Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." ); + } } public void assertTextNotPresent( String text ) { - Assert.assertFalse( getSelenium().isTextPresent( text ), "'" + text + "' is present." ); + try + { + Assert.assertFalse( getSelenium().isTextPresent( text ), "'" + text + "' is present." ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + Assert.assertFalse( getSelenium().isTextPresent( text ), "'" + text + "' is present." ); + } } public void assertElementPresent( String elementLocator ) { - Assert.assertTrue( isElementPresent( elementLocator ), "'" + elementLocator + "' isn't present." ); + try + { + Assert.assertTrue( isElementPresent( elementLocator ), "'" + elementLocator + "' isn't present." ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + Assert.assertTrue( isElementPresent( elementLocator ), "'" + elementLocator + "' isn't present." ); + } } public void assertElementNotPresent( String elementLocator ) { - Assert.assertFalse( isElementPresent( elementLocator ), "'" + elementLocator + "' is present." ); + try + { + Assert.assertFalse( isElementPresent( elementLocator ), "'" + elementLocator + "' is present." ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + Assert.assertFalse( isElementPresent( elementLocator ), "'" + elementLocator + "' is present." ); + } } public void assertLinkPresent( String text ) { - Assert.assertTrue( isElementPresent( "link=" + text ), "The link '" + text + "' isî't present." ); + try + { + Assert.assertTrue( isElementPresent( "link=" + text ), "The link '" + text + "' isî't present." ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + Assert.assertTrue( isElementPresent( "link=" + text ), "The link '" + text + "' isî't present." ); + } } public void assertLinkNotPresent( String text ) { - Assert.assertFalse( isElementPresent( "link=" + text ), "The link('" + text + "' is present." ); + try + { + Assert.assertFalse( isElementPresent( "link=" + text ), "The link('" + text + "' is present." ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + Assert.assertFalse( isElementPresent( "link=" + text ), "The link('" + text + "' is present." ); + } } public void assertImgWithAlt( String alt ) { - assertElementPresent( "/¯img[@alt='" + alt + "']" ); + try + { + assertElementPresent( "/¯img[@alt='" + alt + "']" ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + assertElementPresent( "/¯img[@alt='" + alt + "']" ); + } } public void assertImgWithAltAtRowCol( boolean isALink, String alt, int row, int column ) @@ -153,12 +239,28 @@ public abstract class AbstractSeleniumTest { locator += isALink ? "a/" : ""; locator += "img[@alt='" + alt + "']"; - assertElementPresent( locator ); + try + { + assertElementPresent( locator ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + assertElementPresent( locator ); + } } public void assertCellValueFromTable( String expected, String tableElement, int row, int column ) { - Assert.assertEquals( expected, getCellValueFromTable( tableElement, row, column ) ); + try + { + Assert.assertEquals( expected, getCellValueFromTable( tableElement, row, column ) ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + Assert.assertEquals( expected, getCellValueFromTable( tableElement, row, column ) ); + } } public boolean isTextPresent( String text ) @@ -219,17 +321,41 @@ public abstract class AbstractSeleniumTest { public void assertButtonWithValuePresent( String text ) { - Assert.assertTrue( isButtonWithValuePresent( text ), "'" + text + "' button isn't present" ); + try + { + Assert.assertTrue( isButtonWithValuePresent( text ), "'" + text + "' button isn't present" ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + Assert.assertTrue( isButtonWithValuePresent( text ), "'" + text + "' button isn't present" ); + } } public void assertButtonWithIdPresent( String id ) { - Assert.assertTrue( isButtonWithIdPresent( id ), "'Button with id =" + id + "' isn't present" ); + try + { + Assert.assertTrue( isButtonWithIdPresent( id ), "'Button with id =" + id + "' isn't present" ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + Assert.assertTrue( isButtonWithIdPresent( id ), "'Button with id =" + id + "' isn't present" ); + } } public void assertButtonWithValueNotPresent( String text ) { - Assert.assertFalse( isButtonWithValuePresent( text ), "'" + text + "' button is present" ); + try + { + Assert.assertFalse( isButtonWithValuePresent( text ), "'" + text + "' button is present" ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + Assert.assertFalse( isButtonWithValuePresent( text ), "'" + text + "' button is present" ); + } } public boolean isButtonWithValuePresent( String text ) @@ -346,12 +472,28 @@ public abstract class AbstractSeleniumTest { public void assertIsChecked( String locator ) { - Assert.assertTrue( getSelenium().isChecked( locator ) ); + try + { + Assert.assertTrue( getSelenium().isChecked( locator ) ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + Assert.assertTrue( getSelenium().isChecked( locator ) ); + } } public void assertIsNotChecked( String locator ) { - Assert.assertFalse( getSelenium().isChecked( locator ) ); + try + { + Assert.assertFalse( getSelenium().isChecked( locator ) ); + } + catch ( java.lang.AssertionError e) + { + captureScreenshot(); + Assert.assertFalse( getSelenium().isChecked( locator ) ); + } } } \ No newline at end of file