javascript - PhantomJS onPrompt callback -


i trying onprompt callback working phantomjs.

just testing have basic angular application prompts user on initialization , displays data on page.

it works fine when enter information prompt manually, not work when using phantomjs onprompt callback.

here's angular app:

angular  .module('app')  .controller('test', testcontroller)    function testcontroller() {     var vm = this;     vm.$oninit = oninit;    vm.testdata = '';     function oninit() {      vm.testdata = prompt('name?');    }  } 

this code running phantomjs

var page = require('webpage').create();   page.open('http://localhost:3000', function() {    console.log('test')    page.onprompt = function(msg, defaultval) {     console.log("message", msg)     return "dog";   };   page.render('test.pdf');   phantom.exit();   }); 

i expect console.log says "message" , text prompt , screenshot of page "dog" displayed.

i screenshot of blank page , no console log.

i ideally use callback node webshot option. webshot phantom callbacks

thanks help.

there context in interaction actual interaction page takes place - within page.evaluate(..) function. onprompt callback execute within context , not print console expect - think need marshal output console setting onconsolemessage callback first:

page.onconsolemessage = function (msg) {     console.log(msg); }; 

and should print console expect :)


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -