How do I include screenshots of the full page in m

2019-07-18 04:32发布

问题:

I am using serenity in combination with cucumber for automated screen tests and want to include full-page screenshots in my serenity report. The screenshots in the report are normally only a capture of the viewport. Oftentimes however, this doesn't provide enough information as this is only a part of the screen.

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.

In this discussion I found that this is a common problem for test-automation. Comment 143 mentions this great library for customizing screenshots.

I got this to work in my code, however I would now like to integrate this into the serenity report and this is where I got stuck.

Does anyone know how to replace (or add) the standard screenshot-capturing-part of the serenity using the above library?

I would already be helped a lot if someone could tell me where the screenshot-capturing part of the serenity code is located.. Is it somewhere inside serenity-core?

回答1:

The above mentioned Selenium - Shutterbug library can be used in combination with Serenity-BDD in a PageObject use the following line.

Shutterbug.shootPage(getDriver()).save();

Tip Serenity-BDD fine-tuning screenshots in your living documentation

Through the serenity.properties as shown below:

serenity.take.screenshots.for.tasks=after_each_step
serenity.take.screenshots.for.interactions=for_failure
serenity.take.screenshots.for.questions=after_each_step