I know I can grab the value of a JavaScript variable using Selenium Java APIs as follows
JavascriptExecutor je = (JavascriptExecutor) driver;
Long JSvar = (Long)je.executeScript("return variable");
But is there a way in Selenium to get every value for that variable as it changes in JS code. For example if my JS code looks as follows
var variable=1;
/* some code */
variable=2;
/* some code */
variable=3;
Is there a way to grab these three values (1,2,3)? Something like putting a breakpoint on the JS code but in an automated way. I was thinking that I could store these values in an array and then grab the array but is there another way in Selenium to handle this with the minimal changes to the JS code?