- jayz123
- Posts : 8
Join date : 2012-11-14
How to replace/reset the Selenium's storeEval variable everytime we run the program?
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
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?
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?
Re: How to replace/reset the Selenium's storeEval variable everytime we run the program?
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.
Hope this will help. logic is fine, may be syntax error will come.
Best of luck
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
- pass string variable from database in to variable and then insert into 3rd party website using selenium and click search button.
- How to replace the Original Error message?
- Tutorial for how to use storeEval command to get property of an element.
- two variables in one variable
- Please help.. cant figure out variable!
Permissions in this forum:
You cannot reply to topics in this forum