How to increment values in Selenium IDE for Chrome?

3,772 views
Skip to first unread message

kontotes...@gmail.com

unread,
Mar 9, 2019, 11:33:12 AM3/9/19
to Selenium Users
Hello,

I am a new Selenium user and what I am currently trying to do is increment value (some ID in my system which cannot be the same with every test). I have already created myself a simple but working loop (only for google) but I do not know how to force incrementing values. What I have achieved is adding text to previous value ('1' '1+1' '1+1+1' '1+1+1+1' etc.) but that's not gonna be helpful for tests. If you could possibly tell me how to achieve that as the command storeEval is not working anymore and I cannot find how to replace it. I am sending my commands in attachment, maybe anyone could help. I am using Selenium IDE for Chrome. Thank you in advance.

Kind Regards.


selenium loop.png

Pankaj Doshi

unread,
Mar 11, 2019, 12:00:32 AM3/11/19
to Selenium Users

Bryan L

unread,
Mar 11, 2019, 11:16:34 PM3/11/19
to Selenium Users
You have to execute script and use js to do it now. However, it seems you have to set the value to a number, then use js to add to it. If you don't, the js call treats it as a character and instead of adding via math, it adds as a character.

Such as I want to start with zero 0, then add 1 to it. If treated as character, it ends up as "10", but if treated as math/integer, it ends up as "1". Then if I add another 1 to it, as char "110" as integer "2".

I do this all the time as I have a simple jsp that will allow me to fire custom sql's against a db, then it returns the raw data in a simple table format that I can verify the contents of each cell. There's a very long winded way that I use this data, which has been made much more complicated by the new json format used in the .side files... but I'll deal with that eventually.

Anyway, here's a small snippet, I'm storing the value into a variable called "rowNum":

2019-0311_221048-Snap.jpg

I start by setting rowNum to a 1 on line 67. Then on row 69, I add 1 to it. Row 7 is using that variable to validate the contents in row 2 of an html table via xpath.

Then I add one again to increment it to verify contents of row 3 in the table. And so on.


Hope that helps.

Adam Moondust

unread,
Dec 17, 2019, 6:37:05 AM12/17/19
to Selenium Users
Certainly does help Bryan - as a newby I spent an hour yesterday on this problem, trying out 3 other solutions that didn't work, then I try yours and it does work.
Thanks.
Reply all
Reply to author
Forward
0 new messages