How to debug Javascript code inside page.evaluate () function in PhantomJS?

I have PhantomJS (1.9) script "test.js" (Code taken from PhantomJS docs) -

var webPage = require('webpage');
var page = webPage.create();

page.open('http://m.bing.com', function(status) {

  var title = page.evaluate(function() {
    // >> I have a breakpoint here, but debugger doesnt stop!
    return document.title;
  });

  console.log(title);
  phantom.exit();

});

I am debugging this code with phantomjs --remote-debugger-port=9000 test.jsand chrome.

I can get to all code breakpoints except the code inside page.evaluate(). Is there any way to debug it?

+4
source share

Source: https://habr.com/ru/post/1618086/


All Articles