Sometimes you want to use child/parent like tests.
This enables you to treat the ‘child test’ more like a template which you can re-use. But you might want to influence the variable used in this templated test.
To test whether a variable was set and set it when it was not, you’d do the following.
Testing whether a variable was set is done with this javascript string:
"${randomResellerEmail}" == "$" + "{randomResellerEmail}"
In Selenium IDE this looks like the following.
I use variables all the time. And to be able to re-use a test over and over again, I need random email addresses whenever I fill in forms.
For this I define a variable with the current date and time and then a variable which will hold the email address which uses the current date and time.
My random email address will look like: selenium-20220318_122803@pauledenburg.com
Just store the following as 1 string into the ‘Target’ part of your command.
const date=new Date(); return String(date.getFullYear()) + String(date.getMonth()+1) + String(date.getDate()) + '_' + String(date.getHours() < 10 ? "0"+date.getHours() : date.getHours()) + String(date.getMinutes() < 10 ? "0"+date.getMinutes() : date.getMinutes()) + String(date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds())
It will look like this in Selenium IDE:
Now you can use this to create your email address which is unique every time you run your test:
And use it when you want to fill a form.
We will be installing the following: