出于某种原因,querySelector 和 get element by class 在存在的元素上返回 null。
PhantomJS/SlimerJS
page.open('file:///Users/yeahsame/Desktop/index.html', function(status)
{
console.log("Starting execution");
document.querySelector("input")[0].value = "not working whatsoever";
phantom.exit();
});
HTML:
<!doctype html>
<body>
<input class="form-control email input-lg"></input>
<button class="btn" onclick="location.href='notexist.html'">submit</button>
</body>
在 slimerjs 中运行返回“document.querySelector(...) is null”