javascript - casper js how can i pass varibales from one homade function to another -
okay have started building own modules use in casperjs have come point want pass variable 1 function here have below
my modules -- functions
exports.accdata = function(accnum, amnum) { var accountnumber = casper.fetchtext('div.arabic:nth-child(2) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(' + accnum + ') > td:nth-child(2) > a:nth-child(1)'); var amountwithtype =casper.fetchtext('div.arabic:nth-child(2) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(' + amnum + ') > td:nth-child(4) > div:nth-child(1)'); var redir = accountnumber.substr(1); var split = amountwithtype.split (' '); var amount = split[0]; var type = split[1]; }; exports.job = function (in1, in2){ console.log(in1); console.log(in2); }; and how trying pass casperjs script
casper.then(function(){ universe.accdata("3", "3"); universe.job(amount, type); }); i new , need on how set functions pass data on ,
your accdata function setting bunch of variables not using them. simplest solution put both functions 1 solution might return object first function , pass parameter second function.
exports.accdata = function(accnum, amnum) { return { accountnumber: casper.fetchtext('div.arabic:nth-child(2) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(' + accnum + ') > td:nth-child(2) > a:nth-child(1)'), amountwithtype: casper.fetchtext('div.arabic:nth-child(2) > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(' + amnum + ') > td:nth-child(4) > div:nth-child(1)'), ... }; }; exports.job = function(data) { console.log(data); }; then use this:
casper.then(function() { universe.job(universe.accdata("3", "3")); });
Comments
Post a Comment