Answer the question
In order to leave comments, you need to log in
How to wait for the page to load in phantomJs?
I open the page. It has an authorization form. I fill it in and do submit(). A button with id='install_allow' appears in the same window, which I need to click on. At me it turned out to make only with use of a timeout. How to do it without it?
Here it works:
page_get_code.open(url_get_code, function (status) {
page_get_code.evaluate(function(login, passwd) {
document.querySelector("input[name=email]").value = login;
document.querySelector("input[name=pass]").value = passwd;
document.querySelector("#login_submit").submit();
}, login, passwd);
setTimeout(function(){
page_get_code.evaluate(function() {
document.querySelector("#install_allow").click();
});
}, 3000);
});
page_get_code.open(url_get_code, function (status) {
page_get_code.evaluate(function(login, passwd) {
document.querySelector("input[name=email]").value = login;
document.querySelector("input[name=pass]").value = passwd;
document.querySelector("#login_submit").submit();
}, login, passwd);
page_get_code.includeJs("http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js", function() {
page_get_code.evaluate(function() {
$( document ).ready(function(){
$("#install_allow").click();
});
});
});
});
Answer the question
In order to leave comments, you need to log in
var count_load = 0;
page_get_code.onLoadFinished = function(status) {
count_load++;
if(count_load == 2){
page_get_code.evaluate(function() {
if(document.getElementById("install_allow")){
document.getElementById("install_allow").click();
}
});
}
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question