【发布时间】:2023-04-01 22:20:01
【问题描述】:
我已阅读此phantomjs not waiting for "full" page load,但它并没有解决我的问题。
我试过这个(我的 html,不是完整的):
<div id="test"></div>
<script>
window.onload = function() {
document.getElementById('test').innerHTML = 'something';
console.log('page loaded');
};
</script>
这在我的 js 中:
var page = require('webpage').create();
page.onConsoleMessage = function(msg) {
console.log('here i am');
};
page.onLoadFinished = function() {
console.log('or here!');
}
page.open('http://localhost:3456/calculatorfixture.html', function (status) {
waitFor(function _test(){
return page.evaluate(function() {
return document.getElementById("test").innerHTML == "something";
});
}, function _onReady(){
console.log ("DONE");
phantom.exit();
});
});
我也在截屏 - 仍然没有。我无法让任何 JS 在我的页面上工作。我错过了什么?
【问题讨论】:
标签: javascript phantomjs casperjs