1

ReportNG で失敗したテスト ケースのスクリーンショットを添付するのに助けが必要です。これがどのように正確に行われるかを誰かが説明してくれますか。私はSeleniumとJavaが初めてです。ビルドツールとして Maven を使用しています。

4

3 に答える 3

1

以下のスクリプトを使用して、必要なすべてのクラスでメソッドを呼び出すことができます。

 public void screenCapture() throws IOException{
          System.setProperty("org.uncommons.reportng.escape-output", "false");
          File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
          String Path = "E:\\Automation\\testproject\\Screenshots\\";
          File screenshotName = new File(Path +driver.getTitle()+".png");
          //Now add screenshot to results by copying the file
          FileUtils.copyFile(scrFile, screenshotName);
          Reporter.log("<br>  <img src='"+screenshotName+"' height='100' width='100' /><br>");
          Reporter.log("<a href="+screenshotName+"></a>");

          {
于 2017-09-27T09:50:24.247 に答える