Uh oh!
There was an error while loading. Please reload this page.
add target url as parameter to beforeCaptureJS - #464
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.
ChrisBAshton
commented
Sep 8, 2016
Thanks for the PR @Dahie - but it is already possible to do this with Wraith, see instructions here: https://github.com/BBC-News/wraith/issues/446#issuecomment-241659809 You would apply something along the lines of: module.exports=function(casper,ready){varCURRENT_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. /settingscasper.thenOpen(CURRENT_URL);ready();}); |
Dahie
commented
Sep 8, 2016
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. |
ChrisBAshton
commented
Sep 8, 2016
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. |
Dahie
commented
Sep 8, 2016
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. :) |
KaiHotz
commented
Jan 24, 2017
@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