capybara-screenshot icon indicating copy to clipboard operation
capybara-screenshot copied to clipboard

screenshot_and_save_page only creating the html file in cucumber

Open CID-DAVE opened this issue 9 years ago • 6 comments

My screenshot_and_save_page is only creating the html file. Doing nothing special in the cucumber test just calling that method.

maybe somebody has a solution.

CID-DAVE avatar Jun 18 '16 00:06 CID-DAVE

You're not using a JavaScript driver so no image screenshot. Tag your scenario with @javascript, install a driver like selenium or poltergeist and you'll get your image :)

zedtux avatar Dec 13 '16 07:12 zedtux

Any solution here? I'm using rspec and capybara-screenshot and not doing anything particularly special and only getting the html output.

alexbannon avatar May 25 '18 15:05 alexbannon

For me, the issue was how I was registering drivers. This eventually put me on the right path: https://github.com/mattheworiordan/capybara-screenshot/issues/211#issuecomment-321857907

require "spec_helper"
require "rspec/rails"
require "selenium-webdriver"
require "capybara/rspec"
require "capybara-screenshot/rspec"

Capybara.register_driver :selenium do |app|
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
    chromeOptions: { args: %w(headless disable-gpu) }
  )

  Capybara::Selenium::Driver.new app,
    browser: :chrome,
    desired_capabilities: capabilities
end

Capybara.javascript_driver = :selenium

alexbannon avatar May 25 '18 15:05 alexbannon

Sorry for the delay @alexbannon. Does this issue only happen with headless chrome then? If you are able to provide me with a reproducible bit of code (i.e. ideally a simple app), then I can drop in this gem and work on a more permanent fix.

mattheworiordan avatar Jul 31 '18 21:07 mattheworiordan

If so, this is the same issue as https://github.com/mattheworiordan/capybara-screenshot/issues/211 right?

mattheworiordan avatar Jul 31 '18 21:07 mattheworiordan

Yep looks like it's the same. Feel free to close as a duplicate.

alexbannon avatar Jul 31 '18 21:07 alexbannon