Share
View previous topicGo downView next topic
jayz123
Posts : 8
Join date : 2012-11-14

How to replace/reset the Selenium's storeEval variable everytime we run the program?

on Mon Nov 19, 2012 11:29 am
Hi guys,

I am new to Selenium Rc.
I am working out on a program that will generated random 5 digit numbers based on a button click.
I am using this code to have the generated number
Code:
 String random = selenium.GetEval("Math.floor (Math.random() * 99999)");
          selenium.Type("id=name",random);

First try it will get me 12345 for example.
However, if i am not restarting my application and I click second time on button, the number will become 1234512345. It seem like the it will keep generated another 5 numbers every time i click the button and store in the variable. If i restart my program, it will work well by only generate 5 digits.

I wish is there any solution to handle this problem?
avatar
Advisor
------------------------
------------------------
Posts : 383
Join date : 2009-07-30
Location : India
http://seleniumforum.forumotion.net

Re: How to replace/reset the Selenium's storeEval variable everytime we run the program?

on Mon Nov 19, 2012 8:49 pm
hi,
declare one string variable. put math.floor value into that variable and at start make it null/blank before storing value.

Code:

selenium.GetEval("var digits = null; digits = Math.floor (Math.random() * 99999); return digits;")

Hope this will help. logic is fine, may be syntax error will come.

Best of luck



_________________
Spread Your Knowledge About Selenium Tool.

Administrator
Email: selenium.discussion.thread@live.com
Forum: http://seleniumforum.forumotion.net
View previous topicBack to topView next topic
Permissions in this forum:
You cannot reply to topics in this forum