I'm trying to use Casper JS for the first time and I'm wanting to click on a link, wait for the ajax response and the get the value an element but I cannot seem to figure it out. This is what I have so far:
var casper = require('casper').create();
var phoneNumber = '';
casper.start('https://www.gumtree.com/p/3-bedrooms-rent/3-bed-mid-terrace-house-in-a-lovely-and-peaceful-part-of-hatfield-al10-area/1194478241', function() {
this.waitForSelector( '[data-q="reply-panel-reveal-btn"]' );
});
casper.then(function() {
casper.click( '[data-q="reply-panel-reveal-btn"]' );
});
casper.then( function(){
phoneNumber = document.querySelector('[data-print-key="channel:syi.reveal-phone,key:data"]').innerHTML;
});
casper.run( function(){
console.log(phoneNumber);
});
the end result is just blank, nothing returned in terminal. Anyone have any pointers in where I'm goin wrong?