简体   繁体   English

拍摄网页截图和浏览器窗口

[英]Take screenshot of webpage along with the browser window

I am generating custom reports by implementing IReporter . 我通过实现IReporter生成自定义报告。 I am able to take screenshot of the entire page using the following code 我可以使用以下代码拍摄整个页面的屏幕截图

((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

This captures only the HTML webpage, but I want to capture the browser window as well. 这仅捕获HTML网页,但是我也想捕获浏览器窗口。 Use case for this is say, suppose I check for the title of the page and assert fails. 比如说用例,假设我检查页面的标题并断言失败。 So, when I see the screenshot, I can see what the title of the page was at that time. 因此,当我看到屏幕截图时,可以看到当时页面的标题。

You can get screenshot of the full desktop using Java Robot library. 您可以使用Java Robot库获取完整桌面的屏幕截图。 See this article for implementation details. 有关实现的详细信息,请参见本文

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM