To obtain current time

how to fetch current time using groovy in katalon??

LocalTime now = LocalTime.now()

dosent work:neutral_face:

It does for me.

@anamika You may want to try this

Here is an out-of-box example. Copy and paste this into a new Test Case, and run it.

import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

LocalDateTime now = LocalDateTime.now()
DateTimeFormatter formatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME
String nowString = formatter.format(now)
WebUI.comment("${nowString}")

You will see in the console something like

2019-11-01 09:25:46.661 INFO  c.k.katalon.core.main.TestCaseExecutor   - --------------------
2019-11-01 09:25:46.666 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/TC1
2019-11-01 09:25:47.723 INFO  c.k.k.c.keyword.builtin.CommentKeyword   - 2019-11-01T09:25:47.652
2019-11-01 09:25:47.725 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/TC1

1 Like

thanks it works