Based on the example from the github page I wrote the following code:
// There is some stuff before this that loads the page and do a few clicks but it's not relative to the problem
var selector = 'ContentPlaceHolder1_dtlA_lnkB_0';
nightmare
.evaluate(function (selector) {
return document.querySelector(selector).innerText;
}, selector)
.then(function(text) {
console.log(text);
})
DEBUG=nightmare node checkjobs.js
nightmare queuing process start +0ms
nightmare queueing action "goto" for http://xxxxxxxxx/Login.aspx +3ms
nightmare queueing action "type" +2ms
nightmare queueing action "type" +0ms
nightmare queueing action "click" +0ms
nightmare queueing action "wait" +0ms
nightmare queueing action "click" +0ms
nightmare queueing action "wait" +0ms
nightmare queueing action "click" +0ms
nightmare queueing action "evaluate" +0ms
nightmare running +1ms
nightmare running +16ms
<a id="CContentPlaceHolder1_dtlA_lnkB_0" class="LinkButonDark" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$dtlA$ctl00$lnkB','')" style="color: #97c1e2; text-transform: capitalize;"><b>SOME TEXT I NEED TO CAPTURE</b></a>
In their example I always see .end() before .then()
.
Try this:
var selector = 'ContentPlaceHolder1_dtlA_lnkB_0';
nightmare
.evaluate(function (selector) {
return document.querySelector(selector).innerText;
}, selector)
.end()
.then(function(text) {
console.log(text);
})