Я получаю эту ошибку testNg в консоли
org.testng.TestNGException:
Можно вставить только один из ITestContext, XmlTest, Method, Object [] в аннотированный демонтаж AfterMethod.
Для получения дополнительной информации о внедрении собственных зависимостей, пожалуйста, обратитесь к http://testng.org/doc/documentation-main.html#native-dependency-injection
Мой код для ClassReport Class
public static String getScreenshot(WebDriver driver, String screenshotName) throws IOException{
String dateName = new SimpleDateFormat("yyyyMMddhhmmss").format(new Date());
TakesScreenshot ts = (TakesScreenshot) driver;
File source = ts.getScreenshotAs(OutputType.FILE);
// after execution, you could see a folder "FailedTestsScreenshots"
// under src folder
String destination = System.getProperty("user.dir") + "/FailedTestsScreenshots/" + screenshotName + dateName
+ ".png";
File finalDestination = new File(destination);
FileUtils.copyFile(source, finalDestination);
return destination;
}
И мой код для Aftermethod в тестовом классе ниже
@AfterMethod
public static void teardown(ITestResult result, ExtentTest extentTest) throws
IOException {
if(result.getStatus()==ITestResult.SUCCESS)
{ ext.extentTest.log(LogStatus.PASS,
"test case passed" +result.getName()); ext.extentTest.log(LogStatus.PASS,
"test cases passed "+ result.getThrowable());
String screenshotPath =ext.getScreenshot(driver, result.getName());
ext.extentTest.log(LogStatus.PASS, ext.extentTest.addScreenCapture(screenshotPath));
}
else if (result.getStatus()==ITestResult.FAILURE) {
ext.extentTest.log(LogStatus.FAIL, "test cases failed " +result.getName());
ext.extentTest.log(LogStatus.FAIL, "test cases failed "+ result.getThrowable());
String screenshotPath =ext.getScreenshot(driver, result.getName());
ext.extentTest.log(LogStatus.FAIL, ext.extentTest.addScreenCapture(screenshotPath));
}
ext.extent1.endTest(ext.extentTest);
ext.endReport();
driver.quit();
}