-
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
Add beforeCapture JavaScript hook #279
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NB: this is also pretty useful for sending custom headers with each request! Example code: module.exports = function (casper) {
// load the page with the correct header overrides
casper.open(casper.page.url, {
method: 'get',
headers: {
"data_override": "https://some-data-override-service.bbc.co.uk"
}
});
} (A better way of sending additional headers should be baked into Wraith, but this is a halfway decent hack for the time being. Having the |
align travis with actual ruby version used by wraith use a decent version of Rubygems added casperjs dependency try installing via brew instead reverted travis, back to basics try running first test ??? revert snap_file to what it used to be do we even need this? another attempt at adding the casperjs test it's a long shot, but... :( removed fonts - this just might work
ChrisBAshton
added a commit
that referenced
this pull request
Aug 20, 2015
Add beforeCapture JavaScript hook
Updated docs: http://bbc-news.github.io/wraith/index.html#beforeCapturehooks Also pushed to Rubygems. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Allows the tester to run arbitrary JavaScript on the page before the screenshot is captured. This allows us to regression-test interactive content.
Usage
The global JS will be evaluated before the local JS.
Justification
Some regression tests might incorrectly pass because inconsistencies are not noticeable until some action has been performed (false negative).
Take the In-Depth Toolkit's Clickable Guides, which open panels of informative content when labels are clicked. We had a case recently where the panel text had peculiar margins (inherited from the styling on the host page) but passed regression tests because only the "landing" view was compared.
With this PR, we are able to run JavaScript which clicks on a label and opens a panel: we then take the screenshot and thus are able to regression test content in a particular state.
Before merging
Should probably have some tests in place (though I can't see any tests for using CasperJS to take screenshots of page components - this should probably be added first). The README probably needs updating too - it needs updating anyway to reflect the CasperJS options.
In working this new code into the example configuration, I've cut the default config down to one language (the clickable guide is only on /news). Unfortunately there doesn't seem to be any clickable element on the Russian/Arabic homepages which doesn't take you to a new URL (so it's hard to exhibit the
beforeCapture
functionality)! Perhaps we can put together a better example configuration which shows off more of Wraith's functionality. In summary, we need:But I don't want to do all that if this feature can't be merged for some reason, so let me know! :)