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

Screenshot only works on javascript scenarios? #47

Open golddragon007 opened 5 years ago

golddragon007 commented 5 years ago

I have this settings:

  extensions:
    Behat\MinkExtension:
      browser_name: 'chrome'
      goutte: ~
      selenium2:
        wd_host: 'http://localhost:4444/wd/hub'
        browser: 'chrome'
        capabilities:
          browser: 'chrome'
          chrome:
            switches:
            - "--headless"
            - "--disable-gpu"
      javascript_session: 'selenium2'
      base-url: 'http://localhost:8080/my-site'
      files_path: '/home/user/environment/my-site'
    Drupal\DrupalExtension:
      api_driver: 'drupal'
      blackbox: ~
      drupal:
        drupal_root: '/home/user/environment/my-site'
      selectors:
        message_selector: '.messages'
        error_message_selector: '.messages.error'
        success_message_selector: '.messages.status'
      subcontexts:
        paths:
        - '/home/user/environment/my-site/sites/default'
      drush:
        alias: 'default'
        binary: '/home/user/environment/my-site/vendor/package/toolkit/bin/drush'
      region_map:
        header: "#layout-header"
        featured: ".region-featured-wrapper"
        content_top: ".content-top"
        content: "#content-wrapper"
        left sidebar: "#sidebar-left"
        right sidebar: "#sidebar-right"
        footer: "#layout-footer"
    Bex\Behat\ScreenshotExtension:
      screenshot_taking_mode: failed_scenarios
      image_drivers:
        local:
          screenshot_directory: '/home/user/environment/my-site/tests/screenshots'
          clear_screenshot_directory: true
  formatters:
    pretty: ~

And I noticed it only creates screenshots from the failed scenarios if the scenario is annotated as a javascript scenario. It's not possible to create screenshot if it's not annotated like that? And some why on the screenshot I can see only the text without css... But form the browser it works...

leymannx commented 5 years ago

Yup, only @javascript for now. See #44 and #45.

golddragon007 commented 5 years ago

Hmmm.. it strange, if I set browser_name: 'selenium2' and I delete goutte: ~ then it makes from the non JS scenarios too.

leymannx commented 5 years ago

Seems you made Selenium default, no?

golddragon007 commented 5 years ago

Probably yes, I don't know too much from these options.

tkotosz commented 5 years ago

@golddragon007 Your default mink driver is goutte and that driver doesn't support screenshot taking... when you use the @javascript tag then the selenium2 is used which supports screenshot taking therefore you see screenshots.

One possible solution is to set selenium as default driver. See this comment for more detail: https://github.com/elvetemedve/behat-screenshot/issues/38#issuecomment-315193651

Also related: https://github.com/elvetemedve/behat-screenshot/issues/22