ローカルの ExtentReport にスクリーンショットが表示されない理由がわかりません (ビルド サーバーからはまだ試していません)。これは、takeScreenShot メソッドが呼び出される TestNG @AfterMethod です。
@AfterMethod
public void afterMethod(ITestResult result) throws IOException {
APPLICATION_LOGS.debug("Running @AfterMethod");
switch (result.getStatus()) {
case ITestResult.FAILURE:
childTest.fail(result.getThrowable())
.addScreenCaptureFromPath((takeScreenShot(result.getMethod().getMethodName())));
try {
childTest.info("<a href='https://mywebsite.com/fabrix/logs/s/" + webSessionId + "'" + "target=_'blank'>Data control logs</a>");
} catch (Exception e) {
childTest.info("Unable to get Session ID");
}//.....more code
そして、呼び出されたメソッドは次のとおりです。
private String takeScreenShot(String methodName) {
String path = System.getProperty("user.dir") + "\\target\\reports\\screenshots\\" + methodName + ".png";
try {
File screenshotFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshotFile, new File(path));
} catch (Exception e) {
APPLICATION_LOGS.error("Could not write screenshot" + e);
}
return path;
}
そしてレポート:
[![ここに画像の説明を入力][1]][1]
Chrome 開発者ツールを使用して画像を調べたところ、パスは完璧で、画像はレポートと同じディレクトリに保存されています。では、なぜ表示しないのですか?
IntelliJ から: