Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
hondaman
Posts : 1
Join date : 2012-03-01

Need to randomly generate a DOB in SeleniumIDE Empty Need to randomly generate a DOB in SeleniumIDE

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
avatar
ccox
Master
Master
Posts : 205
Join date : 2012-01-06
Age : 38
Location : Denver, CO

Need to randomly generate a DOB in SeleniumIDE Empty Re: Need to randomly generate a DOB in SeleniumIDE

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.


avatar
Tester Mark
Posts : 6
Join date : 2012-03-10
Age : 109

Need to randomly generate a DOB in SeleniumIDE Empty Re: Need to randomly generate a DOB in SeleniumIDE

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
Sponsored content

Need to randomly generate a DOB in SeleniumIDE Empty Re: Need to randomly generate a DOB in SeleniumIDE

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