How I use time as variable in Katalon Studio?
like robot framework
${time} = Get Time
when I run “sign up” test case, I can input account ${time}, so it is unique.
It will not repeat when I run “sign up” test case every time
Thanks.
How I use time as variable in Katalon Studio?
like robot framework
${time} = Get Time
when I run “sign up” test case, I can input account ${time}, so it is unique.
It will not repeat when I run “sign up” test case every time
Thanks.
Try this…
//ADD to import header in test case
import java.text.SimpleDateFormat
//Google search for SimpleDateFormat for other formats that can be used
String CDATE = new SimpleDateFormat(“MM-dd-yyyy”).format(Calendar.getInstance().getTime());
String CTIME = new SimpleDateFormat(“HH:mma”).format(Calendar.getInstance().getTime());
println('CurrentDate: ’ + CDATE)
println('CurrentTime: ’ + CTIME)
Dave Evers said:
Try this…
//ADD to import header in test case
import java.text.SimpleDateFormat
//Google search for SimpleDateFormat for other formats that can be used
String CDATE = new SimpleDateFormat(“MM-dd-yyyy”).format(Calendar.getInstance().getTime());
String CTIME = new SimpleDateFormat(“HH:mma”).format(Calendar.getInstance().getTime());
println('CurrentDate: ’ + CDATE)
println('CurrentTime: ’ + CTIME)
Thanks Dave,
CDATE works fine.
But how about past date and future date ?
I have beenn using below to get Current date/time in my test case
Date today = new Date()
String todaysDate = today.format(‘dd/MM/yyyy HH:mm’)
It’s work with me and very easy to understand.
thank you, prashant
Would you happen to know how to get date from an element and match it to today’s date to pass a test?
basically,