Unable to take screenshots of Wordpress pages protected behind login
Opened this issue · 0 comments
I'm struggling to use Wraith to check for changes in pages on my Wordpress site, which are protected, meaning that only logged in users can see them. It should be as simple as getting Casper / Phantom to submit the login form at /wp-login.php, then continuing to the page. But, I can't seem to get it to work.
I've tried using casper and phantom, and multiple different methods of loading and filling/submitting the login form. I either get no screenshots at all, or I get screenshots of "You must be logged in to view this page" as if I never submitted the login form at all.
I appreciate any help you can give. Thank you!
Reporting a problem? Please describe the issue above, and complete the following checklist so that we can help you more quickly.
Issue checklist:
-
[ X ] I have validated my config file against YAML Validator to make sure it is valid YAML.
-
[ X ] I have run the
wraith info
command and pasted the output below:
DEBUG: #################################################
DEBUG: Command run: info
DEBUG: Wraith version: 4.2.1
DEBUG: Ruby version: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin14]
DEBUG: ImageMagick: Version: ImageMagick 7.0.7-22 Q16 x86_64 2018-01-26 http://www.imagemagick.org
DEBUG: PhantomJS version: 2.1.1
DEBUG: chromedriver version: ChromeDriver 2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef)
DEBUG: CasperJS version: 1.1.4
DEBUG: #################################################
- [ X ] I have run the command in verbose mode (by adding
verbose: true
to my config) and pasted the output below:
DEBUG: #################################################
DEBUG: Command run: history mydomain.yaml
DEBUG: Wraith version: 4.2.1
DEBUG: Ruby version: ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin14]
DEBUG: ImageMagick: Version: ImageMagick 7.0.7-22 Q16 x86_64 2018-01-26 http://www.imagemagick.org
DEBUG: PhantomJS version: 2.1.1
DEBUG: chromedriver version: ChromeDriver 2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef)
DEBUG: CasperJS version: 1.1.4
DEBUG: #################################################
Config validated. No serious issues found.
Creating Folders
SAVING IMAGES
DEBUG: casperjs '/Users/Duncan/.rvm/gems/ruby-2.4.1@global/gems/wraith-4.2.1/lib/wraith/javascript/casper.js' 'https://mydomain.com/' '1280' 'latest/home/MULTI_casperjs_english.png' 'body' '/Users/Duncan/Sites/wraith/mydomain.com/js/snap.js' 'false'
DEBUG: casperjs '/Users/Duncan/.rvm/gems/ruby-2.4.1@global/gems/wraith-4.2.1/lib/wraith/javascript/casper.js' 'https://mydomain.com/news/' '1280' 'latest/news/MULTI_casperjs_english.png' 'body' '/Users/Duncan/Sites/wraith/mydomain.com/js/snap.js' 'false'
DEBUG: casperjs '/Users/Duncan/.rvm/gems/ruby-2.4.1@global/gems/wraith-4.2.1/lib/wraith/javascript/casper.js' 'https://mydomain.com/afp/' '1280' 'latest/afp/MULTI_casperjs_english.png' 'body' '/Users/Duncan/Sites/wraith/mydomain.com/js/snap.js' 'false'
CURRENT_URL: https://mydomain.com/news/
LOGIN FORM SUBMITTED
BACK TO CURRENT_URL
CURRENT_URL: https://mydomain.com/afp/
LOGIN FORM SUBMITTED
BACK TO CURRENT_URL
CURRENT_URL: https://mydomain.com/
LOGIN FORM SUBMITTED
BACK TO CURRENT_URL
Snapping https://mydomain.com/afp/ at: 1280x1500
Snapping https://mydomain.com/news/ at: 1280x1500
Snapping https://mydomain.com/ at: 1280x1500
- [ X ] I have pasted the contents of my config file below:
browser: "casperjs"
domains:
english: "https://mydomain.com"
paths:
home: "/"
news: "/news/"
afp: "/afp/"
before_capture: "js/snap.js"
screen_widths:
- 1280
resize_or_reload: 'resize'
history_dir: 'base'
directory: 'latest'
fuzz: '20%'
threshold: 10
gallery:
template: 'slideshow_template'
thumb_width: 200
thumb_height: 200
mode: diffs_only
verbose: true
highlight_color: red
js/snap.js:
module.exports = function (casper, ready) {
var CURRENT_URL = casper.page.url;
console.log('CURRENT_URL: '+CURRENT_URL);
casper.open('https://mydomain.com/wp-login.php', function() {
console.log('FILL LOGIN FORM');
this.fill('form#loginform', {
'log': '**********',
'pwd': '***********',
}, true);
});
console.log('LOGIN FORM SUBMITTED');
casper.thenOpen(CURRENT_URL);
console.log('BACK TO CURRENT_URL');
casper.then(function() {
ready();
});
};