README.md in capybara-screenshot-diff-1.5.5 vs README.md in capybara-screenshot-diff-1.6.0
- old
+ new
@@ -36,25 +36,16 @@
### Minitest
In your test class, include the `Capybara::Screenshot::Diff` module:
```ruby
-class FeatureTest < ActionDispatch::IntegrationTest
+class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
include Capybara::Screenshot::Diff
...
end
```
-or if you use the integration test directly:
-
-```ruby
-class ActionDispatch::IntegrationTest
- include Capybara::Screenshot::Diff
- ...
-end
-```
-
### rspec
```ruby
describe 'Permissions admin', :type => :feature, :js => true do
@@ -194,10 +185,27 @@
`screenshot_section` and/or `screenshot_group` can still be overridden in each
test.
+### Capturing one area instead of the whole page
+
+```ruby
+test 'the cool' do
+ visit '/feature'
+ screenshot 'cool_element', crop: bounds('#my_element')
+end
+
+private
+
+def bounds(selector)
+ element = evaluate_script("document.querySelector('#{selector}').getBoundingClientRect()")
+ [element['left'], element['top'], element['right'], element['bottom']]
+end
+```
+
+
### Multiple Capybara drivers
Often it is useful to test your app using different browsers. To avoid the
screenshots for different Capybara drivers to overwrite each other, set
@@ -348,10 +356,10 @@
visit '/'
screenshot 'index', wait: 20.seconds
end
```
-### Removing focus from the active element
+### Hiding the caret for active input elements
In Chrome the screenshot includes the blinking input cursor. This can make it impossible to get a
stable screenshot. To get around this you can set the `hide caret` option:
```ruby