You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ca...@apache.org on 2009/07/16 02:56:26 UTC

svn commit: r794478 - /continuum/branches/continuum-selenium-parallel-carlos/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java

Author: carlos
Date: Thu Jul 16 00:56:26 2009
New Revision: 794478

URL: http://svn.apache.org/viewvc?rev=794478&view=rev
Log:
Ignore errors related to capture screenshots in non firefox browsers

Modified:
    continuum/branches/continuum-selenium-parallel-carlos/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java

Modified: continuum/branches/continuum-selenium-parallel-carlos/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-selenium-parallel-carlos/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java?rev=794478&r1=794477&r2=794478&view=diff
==============================================================================
--- continuum/branches/continuum-selenium-parallel-carlos/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java (original)
+++ continuum/branches/continuum-selenium-parallel-carlos/src/test/testng/org/apache/continuum/web/test/listener/CaptureScreenShotsListener.java Thu Jul 16 00:56:26 2009
@@ -19,12 +19,14 @@
  * under the License.
  */
 
+import static org.apache.continuum.web.test.parent.ThreadSafeSeleniumSession.getBrowser;
+import static org.apache.continuum.web.test.parent.ThreadSafeSeleniumSession.getSelenium;
+
 import java.io.File;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.regex.Pattern;
 
-import org.apache.continuum.web.test.parent.AbstractSeleniumTest;
 import org.testng.ITestResult;
 import org.testng.TestListenerAdapter;
 
@@ -35,14 +37,6 @@
     public void onTestFailure( ITestResult tr )
     {
         captureError( tr );
-        System.out.println( "Test " + tr.getName() + " [" + AbstractSeleniumTest.getSeleniumBrowser() + "] -> Failed" );
-        super.onTestFailure( tr );
-    }
-
-    @Override
-    public void onTestSuccess( ITestResult tr )
-    {
-        System.out.println( "Test " + tr.getName() + " [" + AbstractSeleniumTest.getSeleniumBrowser() + "] -> Success" );
         super.onTestFailure( tr );
     }
 
@@ -54,8 +48,12 @@
         }
         catch ( RuntimeException e )
         {
-            System.out.println( "Error when taking screenshot for test " + tr.getName() );
-            e.printStackTrace();
+            /* ignore errors related to captureEntirePageScreenshot not implemented in some browsers */
+            if ( !e.getMessage().contains( "captureEntirePageScreenshot is only implemented for Firefox" ) )
+            {
+                System.out.println( "Error when taking screenshot for test " + tr.getName() + " [" + getBrowser() + "]" );
+                e.printStackTrace();
+            }
         }
     }
 
@@ -80,8 +78,8 @@
         String className = cName.substring( cName.lastIndexOf( '.' ) + 1 );
         String fileName =
             targetPath.toString() + fs + methodName + "(" + className + ".java_" + lineNumber + ")-" + time + ".png";
-        AbstractSeleniumTest.getSelenium().windowMaximize();
-        AbstractSeleniumTest.getSelenium().captureEntirePageScreenshot( fileName, "" );
+        getSelenium().windowMaximize();
+        getSelenium().captureEntirePageScreenshot( fileName, "" );
     }
 
     private int getStackTraceIndexOfCallingClass( String nameOfClass, StackTraceElement stackTrace[] )