-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PhantomJS not properly rendering websites which use Flexbox #462
Comments
To check if this is something due to my Windows System, I installed a New Ubuntu (Linux) system 14.04 LTS as a VM in my Windows Machine only. The Installation on Ubuntu was a success but the screenshots observed for the above mentioned .yaml file were still same and didn't loaded the page properly even after imparting enough page load time. The Screens shots display the pages that seem visually broken.. |
PhantomJS 1.9.7 isn't very modern - it doesn't even let you use JavaScript's You may want to try upgrading to Phantom 2.1. Also, it would be helpful to paste the entire config - for instance, if you've set your domains to be Other than that, I can confirm that your config seems ok from here, so there's nothing obvious to explain why your pages might not be rendering properly. |
##############################################################
##############################################################
# This is an example configuration provided by Wraith.
# Feel free to amend for your own requirements.
# ---
# This particular config is intended to demonstrate how
# to use Wraith in 'capture' mode, which is best suited to
# comparing a test and live version of the same website.
#
# `wraith capture churchfinder.yaml`
#
##############################################################
##############################################################
# (required) The engine to run Wraith with. Examples: 'phantomjs', 'casperjs', 'slimerjs'
browser: "phantomjs"
# (required) The domains to take screenshots of.
domains:
current: "http://www.churchfinder.com"
new: "This can't be shared due to privacy policy of the company"
# (required) The paths to capture. All paths should exist for both of the domains specified above.
paths:
home: /
# (required) Screen widths (and optional height) to resize the browser to before taking the screenshot.
screen_widths:
- 320x3000
- 600x3000
- 768x3000
- 1024x3000
- 1280x3000
# (optional) JavaScript file to execute before taking screenshot of every path. Default: nil
before_capture: 'javascript/disable_javascript--phantom.js'
# (required) The directory that your screenshots will be stored in
directory: 'shots'
# (required) Amount of fuzz ImageMagick will use when comparing images. A higher fuzz makes the comparison less strict.
fuzz: '20%'
# (optional) The maximum acceptable level of difference (in %) between two images before Wraith reports a failure. Default: 0
threshold: 5
# (optional) Specify the template (and generated thumbnail sizes) for the gallery output.
gallery:
template: 'slideshow_template' # Examples: 'basic_template' (default), 'slideshow_template'
thumb_width: 200
thumb_height: 200
# (optional) Choose which results are displayed in the gallery, and in what order. Default: alphanumeric
# Options:
# alphanumeric - all paths (with or without a difference) are shown, sorted by path
# diffs_first - all paths (with or without a difference) are shown, sorted by difference size (largest first)
# diffs_only - only paths with a difference are shown, sorted by difference size (largest first)
# Note: different screen widths are always grouped together.
mode: diffs_first AND THE DISABLE JAVASCRIPT FILE USED IN THE BEFORE CAPTURE HOOK IS AS FOLLOWS - module.exports = function (phantom, ready) {
// disable JavaScript
phantom.settings.javascriptEnabled = true;
// reload the page without JS enabled
phantom.open(phantom.url, function () {
setTimeout(ready, 5000);
});
} Comment : I Appreciate your help on this. Thanks for the efforts. |
Hi @Sabbi0612 - I've just tried your config locally and I get the same issue, the screenshots look weird. I'm using a modern version of Phantom 2.1.1. You site uses Flexbox (I had a quick look at your site and there is a CSS rule After digging into this in a bit more detail, it appears that there is very limited support for Flexbox even in Phantom 2+. See this discussion. The good news is that they reckon Flexbox will be fully supported in the next major version of PhantomJS. Until then, there isn't really a fix for this. You could try using SlimerJS instead, which is a different rendering engine, but this isn't supported by Wraith out of the box (see #364) so you'd have to write your own snap file, etc. |
@Sabbi0612 Trying PhantomJS 2.5 beta as it appears to have much improved flexbox support. |
@seanw Any luck with 2.5? I installed phantomjs with homebrew, which only provides up to 2.1.1, but could try to manually switch to 2.5 if flexbox support is there |
There is a release date for 2.5? Flex box feature is really f*cking me :( |
This fix worked for us: ariya/phantomjs#14365, as referenced originally by @ChrisBAshton It's a PhantomJS issue. Try putting prefixes in your css for Safari 4! |
Turns out that the Safari fix doesn't solve everything.. A lot, but not everything. To get around, I created a little hack I call 'the casper tweak'. The idea is to have casper set a 'casper-env' class to the body of the headless page (so it will not interfere with the application when displayed through Chrome), and catch up on it in your css to disable flex properties in the application casper is looking at. I am aware that this is far from optimal and goes against every design principle of regressive testing, but in my case the flexbox property was not subjective to the test, but nonetheless the bug rendered the page useless, so I came up with this gist to get around that: https://gist.github.com/automagisch/7ad2be5ee75b27e10111971b6394918b It allows for checking if the env class had been set, and respond in your (s)css to that class change, so I would set a 'display: flex' to 'display: block' for Casper, so I can still test my functionalities :).
|
Hi,
I've tried Implementing Wraith in the project I'm working on and I'm using a System with Windows 8.1 Pro.
Description of Issue :
Wraith Version - 3.2.1
Ruby Version - ruby 2.2.5p319
ImageMagick Version - 7.0.2-7 Q16 x64
PhantomJS Version - 1.9.7
CasperJS Version - 1.1.2
On running the command "wraith capture [filename.yaml]" and after its successful execution when I Observe the screenshots in the "Shots" folder the Screenshots do not contain the JS and CSS elements which makes it look like as if the the Site is broken. The Icons, the Spacing between elements and other elements all are just missing from the Screenshots .The Structure of the site breaks as the images are shifted from their place.
I've tried changing the userAgent and the other settings using a CasperJS script in the before_capture hook as mentioned below. This was done just to check if it was due to the Casper JS Webkit.
I Just want the screenshots to look like as the site looks actually.
Issue checklist:
verbose: true
to my config) and pasted the output below:The text was updated successfully, but these errors were encountered: