I have the next code to take screenshots
public void takeScreenShotOnFailure(ITestResult testResult) throws IOException {
if (testResult.getStatus() == ITestResult.FAILURE) {
System.out.println(testResult.getStatus());
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("errorScreenshots\\" + testResult.getName() + "-"
+ Arrays.toString(testResult.getParameters()) + ".jpg"));
}
}
And it works correctly if I put it into @AfterMethod, but I use PageObject, so I need to put it like a method into the BaseTest and just call it in my @AfterMethod. But when I call it, I have the problem that I do not have anything to put in method`s parameter. If I declare variable testResult like this
ITestResult testResult = new ITestResult();
I have a lot of overridden methods, but it still doesn`t work. What I need to remade for correctly work.
Aucun commentaire:
Enregistrer un commentaire