import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
-import java.util.regex.Pattern;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy.MM.dd-HH_mm_ss" );
String time = sdf.format( new Date() );
File targetPath = new File( "target", "screenshots" );
- StackTraceElement stackTrace[] = failure.getStackTrace();
String cName = this.getClass().getName();
- int index = getStackTraceIndexOfCallingClass( cName, stackTrace );
- String methodName = stackTrace[index].getMethodName();
- int lNumber = stackTrace[index].getLineNumber();
- String lineNumber = Integer.toString( lNumber );
+
+ String methodName = "";
+ int lineNumber = 0;
+
+ for ( StackTraceElement stackTrace : failure.getStackTrace() )
+ {
+ if ( stackTrace.getClassName().equals( this.getClass().getName() ) )
+ {
+ methodName = stackTrace.getMethodName();
+ lineNumber = stackTrace.getLineNumber();
+ break;
+ }
+ }
+
String className = cName.substring( cName.lastIndexOf( '.' ) + 1 );
targetPath.mkdirs();
Selenium selenium = AbstractSeleniumTest.getSelenium();
}
- private int getStackTraceIndexOfCallingClass( String nameOfClass, StackTraceElement stackTrace[] )
- {
- boolean match = false;
- int i = 0;
- do
- {
- String className = stackTrace[i].getClassName();
- match = Pattern.matches( nameOfClass, className );
- i++;
- }
- while ( match == false );
- i--;
- return i;
- }
-
}
\ No newline at end of file