-
Notifications
You must be signed in to change notification settings - Fork 359
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 target url as parameter to beforeCaptureJS #464
base: master
Are you sure you want to change the base?
Conversation
If the website to be captured requires login, often it would redirect to a login-page. This redirect would change the value page.url available in the beforeCaptureJS function. The login could be handled through phantomjs or casperjs, but there is no way to get the original target url. So this change adds the target url as parameter and makes it available in the beforeCaptureJS. It's added as a new parameter at the end so it preserveres backwards-compatibility.
Thanks for the PR @Dahie - but it is already possible to do this with Wraith, see instructions here: You would apply something along the lines of: module.exports = function (casper, ready) {
var CURRENT_URL = casper.page.url;
casper.open('/login.php');
casper.evaluate(function () {
// write your JS which fills in your login form and submits it here
});
// at this point we're now at /dashboard - so need to redirect ourselves to the
// page we wanted to test in the first place, e.g. /settings
casper.thenOpen(CURRENT_URL);
ready();
}); |
We did not get casperjs to work, but that's a different topic. With phantomjs, this is what happens for us: In wraith /lib/javascripts/phantom.js:58 it opens the target url a first time. This target URL requires login, so it redirects to our login page and the callback function within this call already has Thanks for taking the time. |
Ahhh, I didn't realise you had a server-side redirect before the page loads. I don't think Wraith can handle that yet. We will definitely consider merging this PR! Probably ought to write a guide in the GitHub Pages docs too, as login-only pages seem to be a fairly common requirement. |
Yeah, we have server-side redirects. Thanks for considering! :) |
Hi, any news on your considerations? We'd like to see this in wraith and mothball our forked. :) |
@ChrisBAshton Those are nice changes that Dahie proposes, when could we see this integated ? |
Hi,
If the website to be captured requires login, often it would redirect to a login-page. This redirect would change the value page.url available in the beforeCaptureJS function. The login could be handled through phantomjs or casperjs, but there is no way to get the original target url.
So this change adds the target url as parameter and makes it available in the beforeCaptureJS. It's added as a new parameter at the end so it preserves backwards-compatibility with existing configurations.
regards,
Daniel