0
由於某些原因,querySelector和get元素按類在元素上返回null。PhantomJS/SlimerJS通過document.querySelector()找不到元素
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:在slimerjs回報
<!doctype html>
<body>
<input class="form-control email input-lg"></input>
<button class="btn" onclick="location.href='notexist.html'">submit</button>
</body>
運行 「document.querySelector(...)爲空」