如何将截图附加到 Selenium Java Cucumber 的 Azure 报告中。

huangapple go评论71阅读模式
英文:

How to attach screenshot to azure report for selenium java cucumber

问题

我正在Azure DevOps中运行我的Selenium Java测试套件,执行后我能看到结果,但没有附加的失败截图。但是,当我在本地机器上运行时,生成的Cucumber报告包含了截图。

以下是我用于附加截图的代码:

@AfterStep
public void embedScreenshot(Scenario scenario) throws Exception {
    if (scenario.isFailed()) {
        try {
            byte[] scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
            scenario.embed(scrFile, "image/png");
        } catch (WebDriverException somePlatformsDontSupportScreenshots) {
            System.err.println(somePlatformsDontSupportScreenshots.getMessage());
        }
    }
}

有没有插件或其他方法可以在Azure报告中显示失败的截图?

英文:

I am running my selenium java test suit in azure devops, after the execution i am able to see the result, but there is no attachment of failed screenshots. But when i run it in the local machine the cucumber report which is generating contains the screenshot.

Below is the code i have used to attach screenshot

@AfterStep
	public void embedScreenshot(Scenario scenario) throws Exception {
		if (scenario.isFailed()) {
			try {
				byte[] scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES);
				scenario.embed(scrFile, "image/png");
			} catch (WebDriverException somePlatformsDontSupportScreenshots) {
				System.err.println(somePlatformsDontSupportScreenshots.getMessage());
			}
		}
	}

Is there any plugin or anything else i can use to show the failed screenshot in the azure report?

答案1

得分: 0

抱歉,以下是翻译好的部分:

"I afraid there is not a plugin available to show the screenshot in azure report currently. For the screenshot is generated in the .html cucumber report. And azure devops doesnot support publishing generic HTML in build/release pipeline."

"目前,我怕没有可用的插件来显示 Azure 报告中的截图。因为截图是在 .html 青瓜报告中生成的。而 Azure DevOps 不支持在构建/发布流水线中发布通用的 HTML。"

"I guess the test result you saw is under the Tests tab of the azure pipeline build result page. And it is the xml format report which has been published to azure devops, not the html report which contains the screenshots."

"我猜你所看到的测试结果位于 Azure 流水线构建结果页面的 Tests 选项卡下。它是以 XML 格式发布到 Azure DevOps 的报告,而不是包含截图的 HTML 报告。"

"There is feature request regarding this issue which has been submitted to microsoft develop team. You can go vote on it or create one of your own."

"关于这个问题已经提交给 Microsoft 开发团队的 功能请求。你可以投票支持它或创建自己的请求。"

"As a workaround, you can use the publish build artifacts task to publish the screenshots as artifacts of the pipeline."

"作为一种解决方法,你可以使用 发布构建工件任务 将截图作为流水线的工件发布。"

"steps:

  • task: PublishBuildArtifacts@1
    displayName: 'Publish Artifact: TestScreenshots'
    inputs:
    PathtoPublish: '$(System.defaultworkingdirectory)/target/home-page-html' #path to the test result folder(ie. html:target/home-page-html)
    ArtifactName: TestScreenshots"

"步骤:

  • 任务:PublishBuildArtifacts@1
    显示名称:'发布工件:TestScreenshots'
    输入:
    PathtoPublish:'$(System.defaultworkingdirectory)/target/home-page-html' #测试结果文件夹的路径(例如:html:target/home-page-html)
    ArtifactName:TestScreenshots"

"Then you can get the screenshots from the build Summary page, See below:"

"然后,你可以从构建的 概要 页面获取截图,如下所示:"

"If the screenshots reside in multiple test result folders. You can use copy files task to copy the screenshots to a place and then publish to build artifacts."

"如果截图存储在多个测试结果文件夹中,你可以使用 复制文件任务 将截图复制到一个位置,然后发布到构建工件。"

请注意,上述内容是对您提供的英文文本的翻译。

英文:

I afraid there is not a plugin available to show the screenshot in azure report currently. For the screenshot is generated in the .html cucumber report. And azure devops doesnot support publishing generic HTML in build/release pipeline.

I guess the test result you saw is under the Tests tab of the azure pipeline build result page. And it is the xml format report which has been published to azure devops, not the html report which contains the screenshots.

There is feature request regarding this issue which has been submitted to microsoft develop team. You can go vote on it or create one of your own.

As a workaround, you can use the publish build artifacts task to publish the screenshots as artifacts of the pipeline.

steps:
- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: TestScreenshots'
  inputs:
    PathtoPublish: '$(System.defaultworkingdirectory)/target/home-page-html' #path to the test result folder(ie. html:target/home-page-html)
    ArtifactName: TestScreenshots

Then you can get the screenshots from the build Summary page, See below:

If the screenshots reside in multiple test result folders. You can use copy files task to copy the screenshots to a place and then publish to build artifacts.

如何将截图附加到 Selenium Java Cucumber 的 Azure 报告中。

huangapple
  • 本文由 发表于 2020年8月12日 18:16:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/63374449.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定