elvetemedve / behat-screenshot

This is an extension for Behat which provides debugging functionality by taking a screenshot of failed tests.
MIT License
92 stars 17 forks source link

Add HTML fallback in case screenshot taking is not supported by the current driver #45

Open leymannx opened 5 years ago

leymannx commented 5 years ago

Currently screenshots are only taken in JavaScript sessions. Let's add a fallback similar to what integratedexperts/behat-screenshot does, where as fallback an HTML file gets generated using the Goutte driver.

Remaining tasks:

tkotosz commented 5 years ago

I was thinking about this one today and this extension takes screenshots then using the configured image driver it saves the image somewhere (local file system or any remote location). The problem is that the image driver normally expects to get an image, e.g. https://github.com/tkotosz/behat-screenshot-image-driver-uploadpie will upload the image to upload pie. If we would introduce saving html content instead then all the image drivers which expect image would be broken.

Also someone might want to generate the html file anyway even if a screenshot created, etc. All of these would introduce a lot of additional complexity in this extension, so I think the best would be to create a separate extension for this feature.

This way both extension (this one and the new one) will have only 1 responsibility, this one takes screenshots, while the other one dumps html and maybe some additional debug info as well like request headers and stuff like that.

leymannx commented 5 years ago

Thanks for having a look at this one.

I was hoping for some low hanging fruit. Like "(if current driver !== selenium/js) { then parse DOM and save as HTML file and skip all other following tasks that normally are done saving an image }".

One of the biggest positive side effects maybe would be that the extension generates output regardless of the driver, and therefore it may avoid a lot of confusion Behat beginners have about the "screenshot only taken when JS" issues.