TestProject Forum

Unable to create a Local Report - With Customized name appended with time stamp

Hi,

Am using the DriverBuilder class to initiate Chrome, Firefox/Edge browsers

Am using the following methods fr creating local report
.withReportName(report.getName())
.withReportPath(report.getPath())

My Issue is when am trying to append the current date and time along with the report name, driver is not initialized

Hi @vinothone2one

I will try to reproduce this myself and get back to you.

Hello,

I’ve reproduced the issue, and it seems that the cause of failure is because of an illegal character in your file path.

This is the error in console:

Illegal char <:> at index 63: C:\Users\TP\Desktop\Reports\Report2021-06-06T12:55:05.305274700.html

Caused by the ‘:’ in the file name returned from LocalDateTime.now();

You can solve this by specifying a legal date and time format for a filename.

Such as by doing:

DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd-HH-mm");
dtf.format(LocalDateTime.now())

Used the below method and appended to the report name and Its all Good!!! :slight_smile:

private
String currentDateTime() {
Date date = Calendar.getInstance().getTime();
DateFormat dateFormat = new SimpleDateFormat(“yyyy-MM-dd-HH-mm”);
String strDate = dateFormat.format(date);
return strDate;
}

Thanks for your suggestion :slight_smile: