elvetemedve/behat-screenshot

Requirements clarification

Closed this issue · 3 comments

Trying to find my path to screenshots in Behat tests one thing is still unclear to me:

To make use of this pretty nice tool (❤️) we need a JavaScript session with for example Selenium or PhantomJS, yes?

As we need a browser in the first place, is this right?

For example I have the following behat.yml were screenshots are only taken for @javascript tagged scenarios. And I guess that's how it's supposed to work, yes?

default:
  suites:
    default:
      contexts:
        - FeatureContext
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
  extensions:
    Behat\MinkExtension:
      base_url: http://foobar.localhost
      goutte: ~
      selenium2: ~
    Drupal\DrupalExtension:
      blackbox: ~
    Bex\Behat\ScreenshotExtension:
      screenshot_taking_mode: all_scenarios
      image_drivers:
        local:
          screenshot_directory: /tmp/screenshots

Seems to me I'm right. After reading through integratedexperts/behat-screenshot (a somewhat comparable extension) where screenshots are taken in PNG only for JS sessions, and otherwise are taken as HTML file output. Would be a nice feature maybe for bex/behat-screenshot as well, the HTML fallback.

yes, this extension gets the screenshot through the mink driver (see: https://github.com/elvetemedve/behat-screenshot/blob/master/src/Bex/Behat/ScreenshotExtension/Service/ScreenshotTaker.php#L53) so if the mink driver doesn't support taking a screenshot (e.g. goutte driver) then you will not get a screenshot.

Creating a file with the html output in case screenshot taking is not supported by the driver sounds like a good feature. 👍

Thanks a lot for clarifying! This helps me a lot.

I opened a feature request for the HTML fallback: #45