Reputation:
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?
Upvotes: 8
Views: 24123
Reputation: 51
You can use localStorage:
execute script | localStorage.setItem('i', parseInt((localStorage.getItem('i')) || 1)+1)
execute script | return localStorage.getItem('i') | i
echo | ${i}
Upvotes: 0
Reputation: 820
store | 0 | iterator
echo | ${iterator} |
execute script | return parseInt(${iterator}) + 1 | iterator
echo | ${iterator} |
As result will be:
0
1
Upvotes: 4
Reputation: 61
Correct Answer
store | 10 | i
store | javascript{storedVars.i++;} | i
echo | ${i}
Upvotes: 6
Reputation: 2002
This is solution for your problem
store | 10 | i
store | javascript{storedVars.i++;}
echo | ${i}
Upvotes: 4
Reputation: 77201
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.
Upvotes: 1