I am currently using the following method to take screenshots after each test, and it works fine:
@After
public void takeScreenshotAtEndOfTest() throws IOException {
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
String currentDir = System.getProperty("user.dir");
FileUtils.copyFile(scrFile, new File(currentDir + "\\screenshots\\" + System.currentTimeMillis() + ".png"));
}
My question is, how can I improve this method so that it takes the name of the current test that has been run, and puts that into the filename of the image (instead of System.currentTimeMillis)?
This is one of my tests, if that helps:
@Test
public void pf01_activateQsmart_NoAddon_Cash(){
guestWebsite.startOfTest("pf01_activateQsmart_NoAddon_Cash");
doRegularServiceLevelActivation();
doCashPayment();
guestWebsite.endOfTest("pf01_activateQsmart_NoAddon_Cash");
}