I've read this phantomjs not waiting for "full" page load but it didn't solve my issue.
I've tried this (my html, not whole):
<div id="test"></div>
<script>
window.onload = function() {
document.getElementById('test').innerHTML = 'something';
console.log('page loaded');
};
</script>
And this in my 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();
});
});
I was taking screenshots also - still, nothing. I can't get ANY JS to work on my page. What am I missing?