How To Make Phantomjs Wait For A Specific Condition On The Page
I want to realize something like this: function(){ var ua = page.evaluate(function() { while (document.getElementById('td_details87').parentElement.children[11].textC
Solution 1:
There is no blocking sleep()
function in JavaScript. If you want to sleep then you have to use some asynchronous function like setTimeout(callback, timeout)
.
There is a function in the examples folder of PhantomJS that does what you're trying to do. It's waitFor(testFx, onReady[, timeout])
. It works by calling the test function over and over again until it returns a truthy value.
In your case that would look like this:
waitFor(function_test(){
return page.evaluate(function() {
returndocument.getElementById("td_details87").parentElement.children[11].textContent == "Running";
});
}, function_onReady(){
console.log ("DONE");
});
Post a Comment for "How To Make Phantomjs Wait For A Specific Condition On The Page"