Sunday, May 1, 2011

how to increment field value each time selenium test is run?

is there any simple way to increment for example field value by +1 every time Selenium test is run through Selenium IDE?

Command: Type 
Target: some kind of id
Value: number+1

EDIT 1 :thanks for a reply krosenvold. i got your idea and this is a simplified version of what i got so far:

...     
store | 10 | x
storeEval | storedVars['x'] = ${x}+1 | 
...

variable's x value does realy get incremented, but how would you save that value between distinct test runs? is it even possible?

should i get $x value every time the test is run and at the end of it assign $x value to some dummy element on testing page, so i could retrieve that previously incremented value the next time test is run?

From stackoverflow
  • You can use eval;

    eval($('elementId').value = $('elementId').value +1);

    The exact syntax I'm showing implies prototype on the client;

    document.getElementById('elementId').value should also do the trick in a standard dom environment.

0 comments:

Post a Comment