は、
私は絶対パスを使用
注:仲間を検査画像
テイクスクリーンショットの絶対パスを検証するためにブラウザからケン画像:特定ステップにおいて :
ExtentTest.Fail("message", MediaEntityBuilder.CreateScreenCaptureFromPath(TakeScreenShot.TakesScreenshot(driver, "Fatal")).Build());
public static String TakesScreenshot(IWebDriver driver, string FileName)
{
string pathProject = AppDomain.CurrentDomain.BaseDirectory;
string pathScreen = pathProject.Replace("\\bin\\Debug", "");
string path = pathScreen + "project/Test-output/Images/";
StringBuilder TimeAndDate = new StringBuilder(DateTime.Now.ToString());
TimeAndDate.Replace("/", "_");
TimeAndDate.Replace(":", "_");
TimeAndDate.Replace(" ", "_");
string imageName = FileName + TimeAndDate.ToString();
((ITakesScreenshot)driver).GetScreenshot().SaveAsFile(path + "_" + imageName + "." + System.Drawing.Imaging.ImageFormat.Jpeg);
return path + "_" + imageName + "." + "jpeg";
}
プレビュー方式のパスを持つレポートに画像を添付します方法"TakesScreenshot"スクリーンショットを撮ると
バージョンExtentReport:3、 のC#、 NUnitの3
使用してJava:
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
は、次のとおりです。
ExtentTestManager.getTest().log(LogStatus.ERROR, ExtentTestManager.getTest().addScreenCapture("//ABOLUTE/PATH/IMAGE.PNG"));
よろしく。