Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 531
user3416803 Avatar asked Feb 15 '15 08:02

user3416803


1 Answers

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

page.evaluate(function(arg){},arg);
like image 137
Shikiryu Avatar answered Oct 26 '22 11:10

Shikiryu