poltergeist


Render page element with padding in Poltergeist


I would like take screenshot of element with page context, let say 10px around element.
In PhantomJs I would do it
phantom.clipRect = { top: 14, left: 3, width: 400, height: 300 };
phantom.render(output);
I did not find clipRect in Poltergeist.
Is it possible to use phantom.clipRect?
Thanks
I found workaround, to make screenshot of element with 10px around element.
I add dynamically new DOM element 'wrap' and put it around target.
Then I take screenshot of wrap. It work!
Code:
result_file = File.expand_path('../tmp/screenshot.jpg', __FILE__)
browser.execute_script %Q(
// add jQuery
(function(){
function getScript(src, callback) {
var fileref = document.createElement('script');
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", src);
if (callback) {
fileref.setAttribute("onload", callback());
}
document.getElementsByTagName("head")[0].appendChild(fileref);
}
getScript('https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js', function(){
$(function() {
var target = $('#{screenshot_target_selector}');
var offset = target.offset();
var wrap = $('<div id="inlinemanual_screenshot_target_selector_wrap"></div>').prependTo('body');
wrap.css({
position: 'absolute',
width: target.outerWidth() + 20,
height: target.outerHeight() + 20,
top: offset.top - 10,
left: offset.left - 10
});
});
});
}())
)
browser.screenshot_element(result_file, '#inlinemanual_screenshot_target_selector_wrap')

Related Links

How can I use “includeJs” function of phantomjs with poltergeist?
Poltergeist ruby gem fails to process `:shift` modifier in `send_keys`
Using Poltergiest to give user of app a screenshot of their page
Poltergeist 1.9.0 w/Ruby 1.9.3
Post via Capybara and Poltergiest for API testing
Poltergeist current_url command is returning page_info hash instead of a URL
How does one test the content of confirm dialogs using poltergeist?
Using Poltergeist, Phantom JS instances are not exiting during every rspec run
Render page element with padding in Poltergeist
Can I monkey patch the phantomjs browser api with execute_script?
send_keys support for Poltergeist?

Categories

HOME
cloud
vbscript
openmp
netbeans
cookies
magnific-popup
isabelle
spring-jdbc
amazon-ecs
dxl
ckeditor
django-imagekit
podio
synchronization
adfs
gitpitch
primary-key
izpack
wheelnav.js
postgres-xl
n-gram
vb.net-2010
visual-studio-2005
apache-metamodel
riot.js
physics-engine
wkwebview
icloud-api
opennlp
qhull
opentype
facebook-apps
large-file-upload
objectanimator
srcset
lightswitch-2013
fabric8
javascriptcore
karaf
calibre
protovis
wallpaper
mapdb
appfabric
unoconv
eclipse-scout
ibpy
flashair
skeleton-css-boilerplate
scrollable
paxos
hendrix
ionicons
pebble-watch
aurelia-validation
feeds
lift-json
libusb-win32
abcpdf9
ableton-live
savon
home-directory
underscore.js-templating
fputcsv
wapiti
separator
intel-fortran
t4mvc
ruby-2.2
wordml
libressl
coveralls
apache-commons-fileupload
proj4js
javax.mail
kineticjs
tween
camanjs
ceil
p4java
openlaszlo
uv-mapping
ivyde
tidy
listings
pygit2
eventlistener
clipper
bitsharp
libstdc++
coderush
javaspaces
errai
nsmanagedobject
pendrive
work-stealing
fireworks
infobox
pyinotify
thunderbird-lightning
javap
xetex
gacutil
ugc

Resources

Encrypt Message