/**
* this method is called by the Rule before executing a test
+ *
* @throws Exception
*/
public void open()
Assert.assertEquals( getSelenium().getValue( locator ), expectedValue );
}
- public void captureScreenShotOnFailure( Throwable failure, String methodName, String className )
+ public String captureScreenShotOnFailure( Throwable failure, String methodName, String className )
{
SimpleDateFormat sdf = new SimpleDateFormat( "yyyy.MM.dd-HH_mm_ss" );
String time = sdf.format( new Date() );
selenium.windowMaximize();
File fileName = new File( targetPath, fileBaseName + ".png" );
+
selenium.captureEntirePageScreenshot( fileName.getAbsolutePath(), "background=#FFFFFF" );
+ return fileName.getAbsolutePath();
}
}
\ No newline at end of file
public class ArchivaSeleniumExecutionRule
implements MethodRule //TestRule
{
-
+ // FIXME cerate a separate TestRule for open and close calls ?
public Selenium selenium;
public Statement apply( Statement base, FrameworkMethod method, Object target )
}
catch ( Throwable e )
{
- ( (AbstractSeleniumTest) target ).captureScreenShotOnFailure( e, method.getMethod().getName(),
- target.getClass().getName() );
+ String fileName =
+ ( (AbstractSeleniumTest) target ).captureScreenShotOnFailure( e, method.getMethod().getName(),
+ target.getClass().getName() );
+
+ throw new RuntimeException( e.getMessage() + " see screenShot file:" + fileName, e );
}
finally
{
public Statement apply( Statement base, Description description )
{
- return base; //To change body of implemented methods use File | Settings | File Templates.
+ return base;
}
}