java.nio.file.InvalidPathException: Illegal char <:> at index 2: [C:\Users\Myside\Documents\Uploadfiles\test.txt]
at com.kms.katalon.core.util.internal.PathUtil.relativeToAbsolutePath(PathUtil.java:25)
A string literal [C: ... ] contains a colon character : at the index 2.
index 0 â [
index 1 â C
index 2 â :
This is the whole reason why you got the Exception. I guess internally there runs a code like this:
def path = valueAssignedInTheGUI // e.g, '[C: ...'
...
PathUtil.relativeToAbsolutePath(path.toString(), ...)
this will cause the method to raise an Exception if the valueAssignedInTheGUI variable is of type List.
You can read the source code of PathUtils class, and you will find String public static String relativeToAbsolutePath(String relativePath, String projectFolderPath) requires 1st argument to be a string as a valid relative file path. But [C: is not a valid relative file path. Therefore an Exception is raised.
Katalon Studio seems to offer List and File type as variable type but I guess KS is not defensive enough. When a variable fpath is declared as a String, and if the value given is [C: ..., then Katalon Studio GUI should check the validity, find error, and show a modal dialog which warns (before executing the test script)
âa valid file path string is required, but [C: ⌠is not, it looks like a List literal. Type mismatchâ
It is too late to raise an Exception saying shortly âIllegal char <:> at index 2â that puzzle us.
By the way, I do not see why @gsp wrote [C: ... as the Value for the variable fpath.
And I do not see which data type @gsp wants to declare for the variable fpath; String, List? He should chose one. Otherwise he can not decide how he should write a literal as its value: C:... or ["C:..."].
By the way, if he chooses File type, then how he should write the value in the GUI field? â I have no idea, as Java/Groovy language dos not define âa literal for File typeâ.
Conclusion:
I would suggest to him: donât use List and File type as they introduce more troubles than helps. Use String. Simplicity is golden.