Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

» Selenium IDE Verify different Maps (Hybridview, Mapview etc.)
Fri Nov 25, 2016 9:56 pm by DJ87

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Need to randomly generate a DOB in SeleniumIDE

View previous topic View next topic Go down

Need to randomly generate a DOB in SeleniumIDE

Post by hondaman on Thu Mar 01, 2012 6:32 pm

Morning all, im new to thr forum and in need of help,

For one reason or another i need to be able to generate a random, but realistic date of birth. so no more than 100 years old, no younger than 16 years old.

Is this possible to be able to do it in IDE ?

Any help would be apreciated.

Thanks

Blair

hondaman

Posts : 1
Join date : 2012-03-01

Back to top Go down

Re: Need to randomly generate a DOB in SeleniumIDE

Post by ccox on Thu Mar 01, 2012 10:31 pm

Yes this is definitely doable with a custom function in your user-extension file. Basically you would create 3 random numbers, 1-12, 1-29(just in case you do get February), and 1912-1996. Then use the function to return those numbers with "/" between them.



ccox
Master
Master

Posts : 205
Join date : 2012-01-06
Age : 31
Location : Denver, CO

Back to top Go down

Re: Need to randomly generate a DOB in SeleniumIDE

Post by Tester Mark on Sat Mar 10, 2012 2:16 am

hondaman wrote:Morning all, im new to thr forum and in need of help,

For one reason or another i need to be able to generate a random, but realistic date of birth. so no more than 100 years old, no younger than 16 years old.

Is this possible to be able to do it in IDE ?

Any help would be appreciated.

Thanks

Blair

You can generate your values using JavaScript. For example, your year of birth would be:

javascript{Math.floor(Math.random() * (1996 - 1912 + 1)) + 1912} will bring back a random value between 1912 and 1996 (ages 16 through 100).

For the month you can use (as long as you need a numeric value):

javascript{[Math.floor(Math.random() * (12 - 1 + 1)) + 1]}

And for the day:

javascript{[Math.floor(Math.random() * (28 - 1 + 1)) + 1]}

With this, it only returns dates from 1 through 28 (you'll have to figure out the 29th through 31st on your own to get around the issue with February).

To put them all together (with a "/" like ccox mentioned):

javascript{[Math.floor(Math.random() * (12 - 1 + 1)) + 1]+"/"+[Math.floor(Math.random() * (28 - 1 + 1)) + 1] + "/" + [Math.floor(Math.random() * (1980 - 1950 + 1)) + 1950]}

I'm no JavaScript whiz; it took me a while to piece this together, but it's been useful in some scripts that I've put together using the Selenium IDE. I hope that it helps (and 'Hello' from one forum newbie to another Very Happy ).

Mark

Tester Mark

Posts : 6
Join date : 2012-03-10
Age : 102

Back to top Go down

Re: Need to randomly generate a DOB in SeleniumIDE

Post by Sponsored content Today at 10:58 am


Sponsored content


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