What should be used for boolians in Internal Data files? I’ve tried false
, FALSE
, 0
, no
, NO
and nothing works - Katalon always understands it as true
.
I think you can not express boolean value of false in Internal Data. That is a design shortage of Internal Data.
If you need to, you shouldn’t use Internal Data. Use other Data File types: “Excel File”, “CSV File”, “Database Data”.
Why?
Here is an instance of Internal Data I created.
In the “Data Files” folder under the project folder, I found an XML file which contains the following content:
<?xml version="1.0" encoding="UTF-8"?>
<DataFileEntity>
<description></description>
<name>New Test Data (1)</name>
<tag></tag>
<containsHeaders>true</containsHeaders>
<csvSeperator></csvSeperator>
<dataFileGUID>ce6144e6-9054-4bd6-a646-e6910fd2c2a8</dataFileGUID>
<dataSourceUrl></dataSourceUrl>
<driver>InternalData</driver>
<data>null 0 false</data>
<internalDataColumns>
<columnIndex>0</columnIndex>
<name>A</name>
<size>1</size>
</internalDataColumns>
<internalDataColumns>
<columnIndex>1</columnIndex>
<name>B</name>
<size>1</size>
</internalDataColumns>
<internalDataColumns>
<columnIndex>2</columnIndex>
<name>C</name>
<size>1</size>
</internalDataColumns>
<isInternalPath>false</isInternalPath>
<query></query>
<secureUserAccount>false</secureUserAccount>
<sheetName></sheetName>
<usingGlobalDBSetting>false</usingGlobalDBSetting>
</DataFileEntity>
In there I found a line:
<data>null 0 false</data>
I think that this single String holds the value I typed in the GUI.
I noticed that the cell I left WITHOUT any value is represented by a string null
.
As you see, every cells in the GUI of Internal Data are presented as non-empty strings delimited by whitespaces. Every data in Internal Data is in String type. Internal Data has no other data types. It does not know Boolean and Number.
The API of Internal Data class is here:
The constructor of InternalData
class accepts List<String> data
. On the other hand, the getAllData()
method returns an instance of List<List<Object>>
.
I suspect that the getAllData()
method converts an instance of java.lang.String
into a List<String>
. To do that, I suspect that the getAllData()
splits the String by a whitespace as delemiter (" ") to get a List<String>
.
When your test case script refers to a data out of the List<String>
returned by getAllData()
in the context where a Boolean value is required, the Groovy language applies the default rule of data type conversion (coercing) from String to Boolean.
According the language specification of Groovy
5.6. Strings
Non-empty Strings, GStrings and CharSequences are coerced to true.
All of non-empty Strings (“null”, “false”, “FALSE”, “0”, “no”, “NO”) will be evaluated by Groovy to be a boolean value of true. Therefore Internal Data can not hold a value of Boolean false by design.
I wondered why you chose “Internal Data”. I guess, nobody uses it.
Thank you, @kazurayam . I’ll mark your reply as a solution cause, after reading it, now I know what can be used for boolians in Internal Data files:
“Leave the cell empty for *false*
, and put anything (but better something meaningful like ‘TRUE’, ‘True’, ‘true’, ‘YES’, ‘Yes’, ‘yes’, etc.)) for *true*
”
If you are not lazy and assign the values from the file to variable in the script (as I do), you can use your own converter (e.g,‘TRUE’, ‘True’, ‘true’, ‘YES’, ‘Yes’, ‘yes’ → true
; ‘FALSE’,‘False’,‘false’, ‘NO’, ‘No’, ‘no’ → false
or something like this )
I totally agree with you that not doing something like that by Katalon itself is a design shortage of Katalon. I’ve tried to use “Internal Data” cause I assumed that since it’s an internal Katalon solution it would be most efficient and hassle free. Alas, the assumtion seems to be wrong.