Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

» Selecting the input for auto populating element
Sat Jul 29, 2017 7:53 pm by kdabbara

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
avatar
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