javascript - Phantomjs update values of var? -


i have below phantomjs program website contains drop down list ddllevel3

var page = require('webpage').create();      page.onconsolemessage = function(str) {         console.log(str);      }          var z=0; var z_l=0; var op1='#ddldivision' var op2='#ddllevel1' var op3='#ddllevel2' var op4='#ddllevel3'   function selectoption(selector, optionindex) {     page.evaluate(function(selector, optionindex){      var op4='#ddllevel3'          var sel = document.queryselector(selector);     var sel4 = document.queryselector(op4);         sel.selectedindex = optionindex;      var event = document.createevent("uievents"); // see update below     event.inituievent("change", true, false);         sel.dispatchevent(event);     this.dispatchevent(event);      z_l=sel4.length;         console.log("len: "sel4.length+" "+z_l);     }, selector, optionindex); }   page.open(...{ function loop4 () {      selectoption(op4,z);    window.settimeout(function () {           go();                 z++;                            if (z < z_l) {                      loop4();                    }       }, 3000); } loop4(); }); 

i trying run loop4(). value of z_l not changing '0'.

in line console.log("len: "sel4.length+" "+z_l); here values proper.

but not reflected in loop4() in if (z < z_l), , remains 0 always. doing wrong?

i wanted value of z_l updated.i need use page.evaluate , assign z_l below. made these changes in loop4().

function loop4 () {  var z_l = page.evaluate(function() {      var op4='#ddllevel3'         return document.queryselector(op4)    });  selectoption(op4,z); . . . } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -