我无法使用PhantomJS单击按钮。填充文本框非常有效。我想使用纯js(没有jquery)。思想?
var page = require('webpage').create();
page.open('https://www.somepage.com/login', function(status) {
console.log(">page loaded");
page.render('page.png');
page.evaluate(function () {
var username = "";
var password = "";
document.getElementById('login-input').value = username; //works
document.getElementById('passwd').value = password; //works
document.getElementsByName('login_button').click(); //this doesn't click the button
});
console.log(">form submitted");
page.render('page1.png');
phantom.exit();
});