Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Geting issues in identifying the elsements in webdriver
Fri Feb 17, 2017 4:41 pm by janbaskt

» WebDriver - why not to use a singlton for it?
Fri Feb 17, 2017 4:40 pm by janbaskt

» WebDriver session when using testng annotation to invoke driver instance
Fri Feb 17, 2017 4:39 pm by janbaskt

» Selenium fails to launch Chrome
Fri Feb 17, 2017 4:39 pm by janbaskt

» why do i get this error
Fri Feb 17, 2017 4:38 pm by janbaskt

» Selenium Tutorial
Thu Feb 16, 2017 5:21 pm by Rahul

» When to use Selenium IDE, RC and WebDriver
Mon Feb 13, 2017 2:35 pm by azharuddin

» How to integrate selenium with ZAPI-Zephyr
Sat Feb 11, 2017 2:25 am by gseera002c

» Selenium Webdriver
Sat Feb 04, 2017 6:47 pm by soumyamishrav@gmail.com

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

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

View previous topic View next topic Go down

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

Post by jayz123 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?

jayz123

Posts : 8
Join date : 2012-11-14

Back to top Go down

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

Post by Adviser 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

Adviser
------------------------
------------------------

Posts : 379
Join date : 2009-07-30
Location : India

http://seleniumforum.forumotion.net

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum