PhantomJS does not take arguments to function passed to page.evaluate()

帅比萌擦擦* 提交于 2019-12-22 04:50:15

问题


I can't pass arguments to function passed to page.evaluate. I am trying to submit form.

data1 = "Textsample";
page.evaluate(function(data1) {
    var form = document.getElementById ("MyForm");
    form.data.value = data1;
    form.submit();
});

But when I'am taking screenshot of page the data field is filled with "undefined". What am I doing wrong and how to fix it?


回答1:


You need to pass it as 2nd arg in page.evaluate.

page.evaluate(function(arg){},arg);


来源:https://stackoverflow.com/questions/28524130/phantomjs-does-not-take-arguments-to-function-passed-to-page-evaluate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!