tooltrainer 12 Posted July 3, 2010 Report Share Posted July 3, 2010 I'm trying to time the execution of my bot and display a message on completion of how long it ran. Here are the code snippets I'm using... 1. At the start of my bot goes: var start = new Date().getTime(); 2. At the end of the bot goes: var elapsed = (new Date().getTime() - start) / 60000;alert('Total elapsed time: ' + Math.round(elapsed*100)/100 + ' minutes.'); It works perfectly... UNTIL the bot navigates to any page other than the originating one. Then it loses the value stored in "start" completely. Does anyone either know why this is happening, or a way to achieve the result I'm looking for? Thanks! Jonathan Quote Link to post Share on other sites
webautomationlab 21 Posted July 3, 2010 Report Share Posted July 3, 2010 I'm guessing that when you nav, the javascript engine has to reload. You should store the start time in a variable, then you won't have to worry about losing it in your js function. Quote Link to post Share on other sites
tooltrainer 12 Posted July 3, 2010 Author Report Share Posted July 3, 2010 You should store the start time in a variable, then you won't have to worry about losing it in your js function. yeah I tried doing that, can't get it to work either... Here is what I've done: node 1 - set #start eval "var start = new Date().getTime();" node 2 - set #elapsed eval "var elapsed = (new Date().getTime() - {1}) / 60000;" {1} = #start node 3 - set #final_time eval "{1} - {2}" {1} = #elapsed {2} = #start node 4 - set #timer_msg alert('Total elapsed time: ' + Math.round({1}*100)/100 + ' minutes.'); {1} = #final_time node 5 - run javascript alert('{1}'); {1} = #timer_msg Hopefully this makes sense... am I even remotely on the right track here? Jonathan Quote Link to post Share on other sites
webautomationlab 21 Posted July 4, 2010 Report Share Posted July 4, 2010 That "appears" good to me. You should use the UI Monitor to report those variables as they resolve. You can institute delays between nodes to give the stat monitors time to update. It may help you track down the issue. Sorry I can't be more help, I'm not much of a js whiz. I can read what you wrote, but I am not sure how to improve it, or what specific details might be incorrect. Quote Link to post Share on other sites
Net66 54 Posted July 4, 2010 Report Share Posted July 4, 2010 Do all the pages you navigate to have javascript in them? If they don't then eval won't work. Andy Quote Link to post Share on other sites
tooltrainer 12 Posted July 4, 2010 Author Report Share Posted July 4, 2010 Yeah they all do. I bet there's something really subtle that I messed up on... I'll keep messing with it and post back if I figure it out. Jonathan Quote Link to post Share on other sites
tooltrainer 12 Posted August 15, 2010 Author Report Share Posted August 15, 2010 *bump* I was never able to solve this... anyone else have any ideas? I think what's happening is that as soon as i nav to any other page, I lose all the previously created javascript activity, and even though the values are being stored in variables, JS seems unable to access them at the end of the script. Anyone else know how to time activity in UBot across multiple page loads? Jonathan Quote Link to post Share on other sites
IRobot 43 Posted August 15, 2010 Report Share Posted August 15, 2010 Have you checked all the values in post #3 are as expected? An alternative solution is to try using Ubot's built-in System constant > $date, to access the current time. Quote Link to post Share on other sites
tooltrainer 12 Posted August 15, 2010 Author Report Share Posted August 15, 2010 Ooooh that's a great idea! Duh... didn't even occur to me obviously. I'll try that... get date at start, date ad end, subtract the two... voila! Will let you know what happens. Jonathan Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.