问题描述
这个问题是 我问的另一个问题.但是,我已经找到了这部分的答案,并认为它对其他人也有用.我的另一个问题的一部分:
This question is a part of another question I asked. However, I already found the answer to this part and thought it would be useful for other people as well.Part of my other question:
我正在结合使用 serenity 和 cucumber 进行自动化屏幕测试,并希望在我的 serenity 报告中包含整页屏幕截图.报告中的屏幕截图通常只是视口的捕获.然而,这通常不能提供足够的信息,因为这只是屏幕的一部分.
我发现捕获宁静屏幕截图是驱动程序实现的一部分.由于大多数驱动程序都符合 W3C 对屏幕截图的定义,因此这些驱动程序仅捕获当前视口.
I found that the capturing of serenity screenshots is a part of driver implementation. As most drivers conform with the W3C definition of screenshots those drivers only capture the current viewport.
推荐答案
tl;dr: 使用 FirefoxDriver
tl;dr: use FirefoxDriver
我联系了 W3C 的 David Burns.他非常乐于助人,他的回答让我明白了很多.
I contacted David Burns of W3C. He was very helpful and his answer cleared up a lot for me.
首先,FirefoxDriver 目前仍然会截取整个页面.大卫说:
First of all, FirefoxDriver for now still takes screenshots of the full page. David said:
另一方面,FirefoxDriver(以及在 Marionette 中我们的 W3C webdriver 实现)通过将 Document 转储到画布中并在 Canvas 上调用 Firefox 特定 API 来获取屏幕截图来进行屏幕截图.由于我们转储了整个文档,因此我们可以进行整页截图.然而,当我们开始将更多的 Servo 代码放入 Firefox 并且我们访问屏幕截图的方式发生变化时,这种情况可能会发生变化.
所以不幸的是,这可能会在未来发生变化,但现在它很好(当你使用 FFdriver 时)..
So unfortunately this will probably change in the future, but for now it is good (when you use FFdriver)..
他还解释了为什么做出这种选择,并引用了他关于网页呈现如何工作的演讲.后来在我们的谈话中,他还提到了 分钟关于如何截取屏幕截图的讨论.
He also explains why this choice has been made and references to a talk he gave about how the rendering of webpages works.Later in our conversation he also referenced to the minutes of the discussion about how screenshots should be captured.
他的完整回答:
嗨
tl;博士;是否真的很难拍摄全屏照片,因为并非所有浏览器都有信息来创建整个页面的屏幕截图.长版:
The tl;dr; is its really hard take fullscreen shots since not all browsers have the information to create a screenshot of the whole page.Long version:
在今年的 Selenium Conf 上,我谈论 #isDisplayed 有时如何骗你,原因和截图一样.为了使浏览器看起来尽可能快地加载网页,他们通过在 CPU 或 GPU 上进行计算来锻炼需要在视口中渲染的内容,然后渲染它.由于这种方法,这意味着浏览器会建立特定区域的显示列表并创建图块".渲染.它从视口开始并起作用.现在,浏览器不会一次呈现整个页面,它会在您滚动时在上方和下方准备好几次,并在您滚动时计算其余的.
At Selenium Conf this year I did a talk about how #isDisplayed can sometimes lie to you and the reason is the same as the screenshots. To make browsers appear to make web pages load as fast as possible they workout what needs to be rendered in the view port and then render it, via doing calculations on the CPU or GPU.Because of this approach it means that browsers build up a display list of certain areas and creates "tiles" to render. It starts from the viewport and works out. Now, a browser is not going to render a whole page at a time, it will have a few times above and below ready for when you scroll and calculate the rest when you scroll.
现在,ChromeDriver 和 Microsoft 的 EdgeDriver 都从显示列表中截取屏幕截图,并拥有只为它们提供视口的内部 API.这是因为他们的参考测试(或供应商所知的 reftests)只关心这一点.由于边缘情况,他们都觉得做剩下的事情不值得.
Now ChromeDriver and Microsoft's EdgeDriver both do their screenshots from the display list and have internal APIs that only give them the viewport. This is because their reference tests (or reftests as they are known to vendors) only care about that. They both don't feel its worth the effort to do the rest because of the edge cases.
另一方面,FirefoxDriver(以及在 Marionette 中我们的 W3C webdriver 实现)通过将 Document 转储到画布中并在 Canvas 上调用 Firefox 特定 API 来获取屏幕截图来进行屏幕截图.由于我们转储了整个文档,因此我们可以进行整页截图.然而,当我们开始将更多的 Servo 代码放入 Firefox 并且我们访问屏幕截图的方式发生变化时,这种情况可能会发生变化.
FirefoxDriver (and in Marionette our W3C webdriver implementation) on the otherhand does screenshots by dumping the Document into a canvas and calling a Firefox specific API on Canvas to get a screenshot. Since we dump the entire document we can do full page screenshots. This however may change when we start putting more of the Servo code into Firefox and the way we can access screenshots changes.
因为我们只知道它导致我们的视口信息,然后必须将图像拼接在一起以获得完整的页面截图.ChromeDriver 和 IEDriver 都这样做了,两个开发团队都认为这是一个丑陋的 hack,因为它并不总是正确的,而且他们无能为力.
Because we only know the viewport info it leads to us then having to stitch images together to get a full page screenshot. Both ChromeDriver and IEDriver do this and both development teams consider this an ugly hack because its not always right and there isnt much they can do to make it right.
我希望这有助于并很好地解释它.我建议观看我的谈话,因为我解释了浏览器中的渲染和布局引擎是如何工作的.
I hope that helps and explains it well. I suggest watching my talk as I explain how renders and layout engines work in Browsers.
大卫
这篇关于如何在我的 Serenity 报告(而不仅仅是视口)中包含整页的屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!