Tuesday, May 25, 2010

Getting the method name in the method annotated with “@BeforeMethod”

Hi All,

Below is an example that helps to get the test method name, before executing

A quick example for the people who are very lazy like me 


@BeforeMethod
@Parameters("selenium.screenShotFolder")
protected void captureScreenShotBefore(String folder,Method method) {
String data = getSelenium().captureScreenshotToString();
String fileName=method.getName()+"_before.png";
Reporter.log(""+fileName+"");
FileUtil.writeToFile(data,folder+fileName);
}


Thanks & Regards
Balaji

Followers