mattheworiordan / capybara-screenshot Goto Github PK
View Code? Open in Web Editor NEWAutomatically save screen shots when a Capybara scenario fails
License: MIT License
Automatically save screen shots when a Capybara scenario fails
License: MIT License
Great work. How can we not only have it save the HTML on an error, but automatically open it, just like Capybara's save_and_open_page method?
I am testing a Sinatra app. I followed the docs and used require 'capybara-screenshot/cucumber'
in my Cucumber env.rb file. When I ran my test, I got a name error because Capybara::Screenshot
was not loaded. I then used require 'capybara-screenshot'
(no /cucumber) and it complained about launchy missing. After installing the launchy gem all worked fine. So either the docs are wrong or the code is wrong :-)
Whenever I run a scenario in Cucumber with a Scenario Outline (whether ran with/without the --expand option), the failing scenario does not capture a screenshot. However, if I ran the same scenarios in their own individual Scenario, then the screenshot is saved successfully.
Does capybara-screenshot not support Cucumber's Scenario Outline type?
Hi, great gem, but as of rspec 3.1.(4 ?),
require 'capybara-screenshot'
require 'capybara-screenshot/rspec'
should be added to the top of rails_helper.rb, not spec_helper.rb in order for the gem to be be called.
I had a suite of tests always returning exit code 0 regardless of passing or failing scenarios when the project was updated to Ruby 2.1.0. What I thought was a Cucumber issue was actually caused by capybara-screenshot returning an exit code 0 every time. After removing capybara-screenshot it started returning the correct exit code (0 for passing suite, 1 for failing).
If you could give capybara-screenshot 2.1.0 support then it'd be great!
Referenced issue here:
cucumber/common#635
Great tool for spec, but not very usable in cucumber.
Like the "Screenshot path in RSpec metadata" feature there should be a path output that shows which .png file belongs to which test. (no output in 0.3.19)
/usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in require': cannot load such file -- capybara-screenshot/rspec (LoadError) from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in
block in require'
from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in load_dependency' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in
require'
As title, the method is not accessible by just putting in screenshot_and_open_image or Capybara::Screenshot.screenshot_and_open_image.
It's currently:
Automatically save screen shots when a Cucumber Capybara scenario fails
Since capybara-screenshot supports quite a few frameworks by now, I think you could brag a bit more about that ;)
Is there a reason this gem has to depend on Cucumber?
I use Capybara with RSpec request specs and would rather not have to include cucumber and it's dependencies in my bundle (particularly gherkin, which requires native extensions).
This is what I'm getting:
/usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.3/lib/rspec/core.rb:166:in `block in const_missing': uninitialized constant RSpec::Version (NameError)
from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.3/lib/rspec/core.rb:166:in `fetch'
from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rspec-core-3.1.3/lib/rspec/core.rb:166:in `const_missing'
from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-screenshot-1.0.0/lib/capybara-screenshot/rspec/text_reporter.rb:9:in `<module:TextReporter>'
from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-screenshot-1.0.0/lib/capybara-screenshot/rspec/text_reporter.rb:6:in `<module:RSpec>'
from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-screenshot-1.0.0/lib/capybara-screenshot/rspec/text_reporter.rb:5:in `<module:Screenshot>'
from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-screenshot-1.0.0/lib/capybara-screenshot/rspec/text_reporter.rb:4:in `<module:Capybara>'
from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-screenshot-1.0.0/lib/capybara-screenshot/rspec/text_reporter.rb:3:in `<top (required)>'
from /usr/local/var/rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/capybara-screenshot-1.0.0/lib/capybara-screenshot/rspec.rb:1:in `<top (required)>'
from /Users/keithpitt/Development/xxx/spec/support/capybara.rb:5:in `<top (required)>'
I think it should be:
>> RSpec::Core::Version::STRING
=> "3.1.3"
I would like to use this gem to generate screenshots for every step in my cucumber features. Additionally, I would like to embed the screenshots within the html formatted output report when running `cucumber features/* -f html -o output.html
I do not see an easy way to automatically generate screenshots for every step or embed within reports. Also, my pages seem to be wider than the screenshots. Is the screenshot width configurable?
Hello, I am try to use your awesome gem with cucumber+capybara(2.1). It was perfect for capybara(2.0), but now autosave when scenario failed not working. Could you add support for capybara 2.1?
Thank you
On rspec errors, I get a message
Screenshot: [some file path]
However, there's no file.
I've got the following gem versions:
capybara (2.1.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
capybara-screenshot (0.3.14)
capybara (>= 1.0, < 3)
launchy
I use rspec + capybara (webdriver). I used it today for the first time, it woks great. Just that i saw an extra browser instance being opened.
Screenshot seems to run on all examples, regardless of type. Normally this isn't an issue, as it doesn't produce a screenshot if Capybara isn't running. But in a model spec, it still tries, which causes Capybara to fire a request to the test server. Webmock will block this by default, as the request has not been stubbed for the example, causing the test to fail as in the example below.
Real HTTP connections are disabled.
Unregistered request: GET http://127.0.0.1:7777/__identify__ with headers
{'Accept'=>'*/*', 'Accept-
Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Ruby'}
Setting Capybara::Screenshot.autosave_on_failure = false
in config.before(:each)
does not help since it is checked after if Capybara.page.respond_to?(:save_page)
, which I assume is what fires off the identify request.
Am I missing a config option here? If none already exists, I think the lowest impact way to fix this would be to add a configuration that allows you to completely disable screenshot for certain test types, or move the Capybara::Screenshot.autosave_on_failure
check above the Capybara.page.respond_to?(:save_page)
check so that it never launches Capybara unless it needs to.
Let me know if I'm missing something obvious. Otherwise happy to create a pull request.
Not to give you the double-whammy, but I just found this problem even on 0.2.2.
With the same Gemfile as I included in my other logged issue, the following spec,
require 'spec_helper'
describe "UserActivations" do
it "sends a user activation email when user is created" do
visit login_path
click_link "Register"
<...snip...>
end
end
will fail with the following message:
1) UserActivations sends a user activation email when user is created
Screenshot: /Volumes/.../tmp/capybara/screenshot-2012-10-26-15-27-09.png
Failure/Error: visit login_path
NoMethodError:
undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_1:0x00000103359158>
# ./spec/requests/user_activation_spec.rb:6:in `block (2 levels) in <top (required)>'
If I add a context wrapper around the test,
require 'spec_helper'
describe "UserActivations" do
context "when activating a user" do
it "sends a user activation email when user is created" do
visit login_path
click_link "Register"
<...snip...>
end
end
end
everything works as expected:
UserActivations
when activating a user
sends a user activation email when user is created
Finished in 3.42 seconds
1 example, 0 failures
We have a rails app that we are testing with capybara-screenshot. Our application is built with Backbone.js, and we are using the capybara-webkit driver and cucumber for testing. When we write a test that views a page that has a "modal dialog"... which we create from the bootstrap CSS library (e.g. twitter's css framework), our modal dialogs are not appearing as part of the screen shot.
I noticed that the poltergeist driver https://github.com/jonleighton/poltergeist has an option to save the entire page.
"...By default, only the viewport will be rendered (the part of the page that is in view). To render the entire page, use
page.driver.render('/path/to/file.png', :full => true).
..."
(That said, we'd rather use the webkit driver.)
Here is an example of a modal dialog with Bootstrap from twitter:
http://twitter.github.com/bootstrap/javascript.html#modals
(Click the Launch modal demo button.) We have tried to put a delay in our tests to allow the modal to load, but that has not helped either.
I am a bit out of my depth here and apologize if this is short on technical details. Being able to save the modal dialogs that are begin generated by the Bootstrap framework from twitter would be huge for us.
Thanks for any help you can provide, and thanks for a great tool!
Miles.
Hi,
First of all, thanks for the gem!
I tried it at work where we use RSpec for our integration tests and it worked great. I couple your "screenshot_and_open_image" with Capybara's "save_and_open_page" to get both an HTML page (without any CSS styling) and a nice-looking image (.png file, I think). Great!
I am now trying it at home on a different project which uses cucumber. I have the necessary "require capybara-screenshot/cucumber" statement in my env.rb file. (BTW: cucumber-rails 1.3.0, capybara 2.0.2, capybara-webkit 0.14.0, capybara-screenshot 0.3.3 on Ubuntu 12.04 and Firefox 17.0.1)
The problem is that I am not getting any images. When I put "screenshot_and_save_page" in a step-def, a "screenshot_2013-01-09-xxxx.html" file is being generated in /tmp/capybara, so the plumbing hook-up looks okay. And that HTML file is the same as the HTML file that is produced when I use Capybara's "save_and_open_page" method.
Question 1: Should this HTML file contain a .png file which actually shows an image of the page or should it just show the vanilla HTML (i.e. with no CSS styling) - which makes it identical to Capybara's built-in "save_and_open_page" method?
Question 2 (And this is the more important one): When I also insert a call to "screenshot_and_open_image" -- nothing. Am I missing something or does it just not produce images for Cucumber like it did for RSpec?
Thanks,
Larry
Does this work on OS X or just in Linux? I'm running on Lion and things are working as they should, except nothing is being saved to the /tmp/capybara folder, whether I run with my own code or the sample app that you created. Any idea what's up?
I'm sure this is my own configuration issue, but this used to work and I'm not sure what else to try. If you would prefer this be an issue on SO, just let me know -- I'm trying to follow your instruction in the README by posting here :).
My, somewhat intense, spec_helper.rb (e.g. I'm making the explicit require call).
A sample spec results in:
Run options: include {:only=>true}
All examples were filtered out; ignoring {:only=>true}
Showroom
without being logged in
adding a vehicle from a search result vehicle card
webkit
2013-06-05 10:42:10.556 webkit_server[82805:707] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
drops open the showroom (FAILED - 1)
Failures:
1) Showroom without being logged in adding a vehicle from a search result vehicle card drops open the showroom
Screenshot: <project>/tmp/capybara/screenshot_2013-06-05-10-42-16.585.png
Failure/Error: find("#showroom").should be_visible
Capybara::ElementNotFound:
Unable to find css "#showroom"
# ./spec/features/web/showroom_spec.rb:18:in `block (4 levels) in <top (required)>'
Finished in 6.76 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/features/web/showroom_spec.rb:15 # Showroom without being logged in adding a vehicle from a search result vehicle card drops open the showroom
Screenshot: <project>/tmp/capybara/screenshot_2013-06-05-10-42-16.585.png
Randomized with seed 3046
But my tmp/capybara
directory is empty.
The QT warning is apparently not an issue.
I've tried combinations for passing/failing explicit save/open calls that I can think of, and I always get no image opened, and no images saved, or an error like this (which is probably just because there is no file to open?):
Failure in opening <project>/tmp/capybara/screenshot_2013-06-05-10-40-34.236.png with options {}: No application found to handle '<project>/tmp/capybara/screenshot_2013-06-05-10-40-34.236.png'
Any thoughts? Any help is greatly appreciated!
capybara-screenshot could not detect a screenshot driver for 'rack_test'. Saving with default with unknown results.
An error occurred in an after hook
NoMethodError: undefined method render' for #<Capybara::RackTest::Driver:0x0000001156cc30> occurred at /home/prusswan/.rvm/gems/ruby-1.9.3-p194/gems/capybara-screenshot-0.2/lib/capybara-screenshot/saver.rb:34:in
save_with_default'
Is this supposed to be normal? Even if it is, is there a way to configure capybara-screenshot not to take screenshots for the default driver?
Ruby-1.9, Capybara-1.1.4, Selenium-WebDriver-2.32.1
I am using capybara-screenshot
0.3.21, capybara
2.4.1 and rspec
3.1.0 and when I run a failing spec I don't see a link to the produced png/html. I haven't set Capybara::Screenshot::RSpec.add_link_to_screenshot_for_failed_examples = false
. Is this a known issue?
We register a selenium Firefox driver named ':firefox'. Screenshots don't get taken for this driver, because saver.rb explicitly checks for a driver named ':selenium'.
Capybara.register_driver :firefox do |app|
Capybara::Selenium::Driver.new(app, :browser => :firefox)
end
From saver.rb:
case capybara.current_driver
...
when :selenium
capybara.page.driver.browser.save_screenshot(screenshot_path)
else
#Uh-oh! Our selenium driver named ':firefox' falls through to here and doesn't get handled
Pretty easy to fix by checking responds_to?(:save_screenshot)
instead of looking at the driver name -- I'll try to send a pull request.
Hi, I got this error, and it's normal because don't have anymore a util folder, I surprise that no one got this errors. Did I do something wrong?
After updating to 0.1.5, I get this error on initialisation, from lib/capybara-screenshot/minitest.rb:4
.
I'm using Rails 3.1.3 and Ruby 1.9.2, but the project was created with --skip-active-record --skip-test-unit
, in case that makes a difference.
Perhaps it would be safer to check that ActionDispatch::IntegrationTest
is not only defined, but also responds to #add_teardown_hook
.
I have a project that has an RSpec unit test suite and an RSpec integration test suite. Capybara is only used in the integration test suite. As per the installation steps in the readme, I added require 'capybara-screenshot/rspec'
to spec_helper.rb. Now when I get failures in my unit tests, I get a message with a path to a screenshot in the failure message. I looked at rspec.rb in this gem to see how it decides when to save screenshots and it looks like as long as Capybara.page.respond_to?(:save_page)
and Capybara::Screenshot.autosave_on_failure && example.exception
are true then a screenshot will be saved. In both of my test suites those are always true. Is there something I'm missing here?
I was able to work around the issue by adding require 'capybara-screenshot/rspec'
in my own rake task that I use for running the integration test suite, but it seems like there should be a cleaner solution. What do others do to not run into this issue? Another option I see is to have a integration_spec_helper.rb which could be included instead of spec_helper.rb in integration tests and I'd added the reference to capybara-screenshot only in integration_spec_helper.rb. I might have to go with this approach because even with my workaround, if I want to run a single integration test file using rspec path/to/integration_spec.rb
I don't get capybara-screenshot.
I also have another situation where I have tests in my integration suite that don't use Capybara, but just test the integration between certain classes, and in those tests I also don't want capybara-screenshot active. My workaround now is to add the following to the outer describe in those files:
before(:all) { Capybara::Screenshot.autosave_on_failure = false }
after(:all) { Capybara::Screenshot.autosave_on_failure = true }
But that seems hacky. Is there a better solution there as well?
Thanks.
Failure/Error: prepare_merchant_for_testing!
NoMethodError:
undefined method `root' for Rails:Module
# /Users/pavel/.rvm/gems/ruby-1.9.3-p327/gems/capybara-screenshot-0.3.17/lib/capybara-screenshot.rb:49:in `capybara_root'
# /Users/pavel/.rvm/gems/ruby-1.9.3-p327/gems/capybara-screenshot-0.3.17/lib/capybara-screenshot/saver.rb:50:in `screenshot_path'
# /Users/pavel/.rvm/gems/ruby-1.9.3-p327/gems/capybara-screenshot-0.3.17/lib/capybara-screenshot/saver.rb:35:in `save_screenshot'
# /Users/pavel/.rvm/gems/ruby-1.9.3-p327/gems/capybara-screenshot-0.3.17/lib/capybara-screenshot/saver.rb:19:in `save'
# /Users/pavel/.rvm/gems/ruby-1.9.3-p327/gems/capybara-screenshot-0.3.17/lib/capybara-screenshot.rb:27:in `screenshot_and_open_image'
# /Users/pavel/.rvm/gems/ruby-1.9.3-p327/gems/capybara-screenshot-0.3.17/lib/capybara-screenshot/capybara.rb:11:in `screenshot_and_open_image'
Running into an issue where no screenshots are created while running spork. Has anyone else seen this behavior?
I first noticed that it wasn't triggering on failed integration tests. I've tried calling it manually via the following.
Capybara::Screenshot::Saver.screen_shot_and_save_page Capybara, Capybara.body
page.driver.render Rails.root.join("tmp/capybara/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.png")
I do get screenshots when I turn off spork though.
Saved file /home/jenkins/workspace/Cucumber-Tests/tmp/capybara/screenshot_2014-01-31-18-11-27.068.html
Given an unsubscribed male user "MrMangione" # features/step_definitions/user_steps.rb:263
File name too long @ rb_sysopen - data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA+gAAAdHCAYAAABRplPMAAAgAElEQVR4nOyd
55sUxf72f3/AeY4CuzupZ6Zz98xsJGOARYKSJJrASBBQzOmYc87p6DEQRDJI
....
....
oAMAAAAAYIAf6+//A0mHKM/RBj9BAAAAAElFTkSuQmCC
(Errno::ENAMETOOLONG)
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/formatter/gherkin_formatter_adapter.rb:86:in initialize' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/formatter/gherkin_formatter_adapter.rb:86:in
open'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/formatter/gherkin_formatter_adapter.rb:86:in embed' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:181:in
block in send_to_all'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:179:in each' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:179:in
send_to_all'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:173:in broadcast' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:160:in
embed'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime/user_interface.rb:54:in embed' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/rb_support/rb_world.rb:117:in
After'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/core_ext/instance_exec.rb:36:in cucumber_instance_exec' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/rb_support/rb_hook.rb:14:in
invoke'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/language_support/language_methods.rb:114:in invoke' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/language_support/language_methods.rb:108:in
block in execute_after'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/language_support/language_methods.rb:107:in reverse_each' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/language_support/language_methods.rb:107:in
execute_after'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/language_support/language_methods.rb:19:in after' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime/support_code.rb:112:in
block in fire_hook'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime/support_code.rb:111:in each' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime/support_code.rb:111:in
fire_hook'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime.rb:113:in after' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime.rb:100:in
before_and_after'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime.rb:82:in block in with_hooks' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime/support_code.rb:120:in
call'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime/support_code.rb:120:in block (3 levels) in around' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/language_support/language_methods.rb:9:in
block in around'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/language_support/language_methods.rb:94:in call' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/language_support/language_methods.rb:94:in
block (3 levels) in execute_around'
/home/jenkins/workspace/Dating-Cucumber-Tests/features/support/env.rb:81:in call' /home/jenkins/workspace/Dating-Cucumber-Tests/features/support/env.rb:81:in
block in <top (required)>'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/core_ext/instance_exec.rb:48:in instance_exec' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/core_ext/instance_exec.rb:48:in
block in cucumber_instance_exec'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/core_ext/instance_exec.rb:69:in cucumber_run_with_backtrace_filtering' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/core_ext/instance_exec.rb:36:in
cucumber_instance_exec'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/rb_support/rb_hook.rb:14:in invoke' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/language_support/language_methods.rb:114:in
invoke'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/language_support/language_methods.rb:93:in block (2 levels) in execute_around' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/language_support/language_methods.rb:97:in
call'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/language_support/language_methods.rb:97:in execute_around' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/language_support/language_methods.rb:8:in
around'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime/support_code.rb:119:in block (2 levels) in around' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime/support_code.rb:123:in
call'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime/support_code.rb:123:in around' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime.rb:94:in
around'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime.rb:81:in with_hooks' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:13:in
execute'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/scenario.rb:32:in block in accept' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/scenario.rb:79:in
with_visitor'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/scenario.rb:31:in accept' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:58:in
block in visit_feature_element'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:170:in broadcast' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:57:in
visit_feature_element'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/feature.rb:38:in block in accept' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/feature.rb:37:in
each'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/feature.rb:37:in accept' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:27:in
block in visit_feature'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:170:in broadcast' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:26:in
visit_feature'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/features.rb:28:in block in accept' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/features.rb:17:in
each'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/features.rb:17:in each' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/features.rb:27:in
accept'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:21:in block in visit_features' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:170:in
broadcast'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/ast/tree_walker.rb:20:in visit_features' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/runtime.rb:49:in
run!'
/home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/lib/cucumber/cli/main.rb:47:in execute!' /home/jenkins/.gems/ruby/2.1.0/gems/cucumber-1.3.10/bin/cucumber:13:in
<top (required)>'
/home/jenkins/.gems/ruby/2.1.0/bin/cucumber:23:in load' /home/jenkins/.gems/ruby/2.1.0/bin/cucumber:23:in
On my setup, the Saver never saves anything because of line https://github.com/mattheworiordan/capybara-screenshot/blob/master/lib/capybara-screenshot/saver.rb#L25 where capybara.current_path is always nil
I can use it manually but I don't really see the point…
PS: is it possible to set the file names to ?
The screenshots in our application appear to no longer be captured until after the after(:each) block has been run. This makes the screenshot inaccurate in cases where the after block navigates from the page (such as logging out)
If I remove the after block, the screenshot is captured at the point of failure.
4247c42 pulls in the GPL-licensed colorize gem as a dependency. Some people working for companies with strict license policies may not be able to use capybara-screenshot at work as a result. Thought I'd mention it in case it's something you hadn't considered.
When there is a failure and the screenshot is generated, I'd like to have the screenshot opened immediately in a viewer. Something like open filename
would work on Mac. Where would I hook in to do this?
I've not time to figure out what is going on but when I use your gem, visit (or actually any normal helper method) just up and takes out. Then when I remove your gem from my rails Gemfile it comes back. I'm using RSpec 2 if that helps any.
I was able to get screenshot on failure using "save_screenshot(path)" as mentioned in one of the comments in the issues.
But, I am still not able to get to append that screenshot path to the spec html report.
According to the readme doc, it works by default but looks like something is missing. Is there any other hidden configuration/command like the one above that will do the trick?
Please help if anyone had the same issue and was able to resolve it.
When I use capybara-screenshot to take a screenshot it outputs something like "Saved file screenshot_2013-09-12-17-03-47.247" in console, is there anyway to disable this? Thanks!
Is there possible to have only 10 | 50 | 100 last screenshots?
My tmp/ folder quickly turns into a mess when I deal with failing tests.
Hello,
I'm running capybara-screenshot without Cucumber, just Rspec request specs + capybara-webkit and I noticed that images are being generated for all tests and not only for failing ones. Is there any configuration that I need to make in order to fix this?
Thanks!
Backtrace snippet:
undefined method configure' for RSpec:Module /Users/agranov/.rvm/gems/ruby-1.9.2-p320@dotBusy32/gems/capybara-screenshot-0.2.4/lib/capybara-screenshot/rspec.rb:1:in
<top (required)>'
/Users/agranov/.rvm/gems/ruby-1.9.2-p320@dotBusy32/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in require' /Users/agranov/.rvm/gems/ruby-1.9.2-p320@dotBusy32/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in
block in require'
/Users/agranov/.rvm/gems/ruby-1.9.2-p320@dotBusy32/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in load_dependency' /Users/agranov/.rvm/gems/ruby-1.9.2-p320@dotBusy32/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in
require'
/Users/agranov/.rvm/gems/ruby-1.9.2-p320@dotBusy32/gems/capybara-screenshot-0.2.4/lib/capybara-screenshot.rb:104:in `<top (required)>'
I've made sure that it's being loaded last in Gemfile.
Reverting back to 0.2.2 fixes the issue.
Not sure if this is a capybara-screenshot error, or a Poltergeist error (or my error)...
I am getting this error displayed in all my screenshots after I call click_button
.
I don't know why, if I take a screenshot prior to this, they come out as expected.
I am using Poltergeist. I tested this scenario manually and it works...
Here is a test snippet:
describe 'xyz' do
it ' does ABC' do
user = Fabricate(:user)
visit '/sign_up'
puts User.count # returns 1
screenshot_and_open_image # works
fill_in 'Email', with: user.email
fill_in 'Password', with: user.password
fill_in 'Password confirmation', with: user.password
screenshot_and_open_image # works
click_button 'Sign Up!'
screenshot_and_open_image # Shows error
assert true
end
end
It should be clarified in the README that capybara-screenshot/minitest has a hard dependency on ActionDispatch. This is important for those of us who are using capybara and minitest to integration test non-rails or 3rd party applications and thus aren't making use of Action::Dispatch::IntegrationTest.
I followed the instructions in the ReadMe and got the following error;
/home/gsimpson/.rvm/gems/ree-1.8.7-2011.03@myproject/gems/capybara-1.1.1/lib/capybara/cucumber.rb:6: undefined method `World' for main:Object (NoMethodError)
I'm using Rails 3.1.1 and all my gems are pretty up to date.
Cheers,
Graeme
For some reason, when we only use RSpec (no rails application), running a simple test (snippet hosted here: https://gist.github.com/2784244) which fails, no directory or screenshot is generated under $app_root/tmp/capybara (cannot find /tmp folder)
Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec,
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
Even for projects that already specify a license, including a license in your gemspec is a good practice, since it is easily
discoverable there without having to check the readme or for a license file. For example, it is the field that rubygems.org uses to display a gem's license.
For example, there is a License Finder gem to help companies ensure all gems they use
meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough
issue that even Bundler now generates gems with a default 'MIT' license.
If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), github has created a license picker tool.
In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :).
I hope you'll consider specifying a license in your gemspec. If not, please just close the issue and let me know. In either case, I'll follow up. Thanks!
p.s. I've written a blog post about this project
Title is relatively explanatory.
A user can specify where they want the '.html' files saved, but for the '.png', if you are not running Rails or Sinatra, seems you are SOL for the time being.
The fix is (most likely) pretty simple. it would be nice if you could add this functionality in the near future...seems to be pretty low-hanging fruit.
Thanks for maintaining such a useful tool,
wokkaflokkaflame
Hello.
Is there a way to solve this?
My spec_helper.rb has this:
...
require 'capybara/rspec'
require 'capybara/rails'
...
require 'capybara-screenshot/rspec'
...
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
Capybara.javascript_driver = :chrome
Capybara.default_driver = :chrome
Error occurs whenever test fails or I try to create screenshot manually.
An error occurred in an after hook
NoMethodError: undefined method render' for #<Capybara::Selenium::Driver:0xbe790b8> occurred at C:/VirVit/Ruby200/lib/ruby/gems/2.0.0/gems/capybara-screenshot-0.3.19/lib/capybara-screenshot.rb:73:in
block (2 levels) in <top (required)>'
gemfile.lock is:
capybara (2.2.1)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (> 2.0)> 2.2.0)
capybara-email (2.3.0)
capybara (
mail
capybara-screenshot (0.3.19)
capybara (>= 1.0, < 3)
launchy
Thank you in advance! :)
I have to call the full method, ala:
Capybara::Screenshot.screenshot_and_open_image
For whatever reason, just calling screenshot_and_open_image
by itself is not found in the Capybara DSL. Just a small annoyance, probably something I'm missing.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.