Data driven testing for EggPlant Windows

I am new to eggplant and have a question. I have a scenario where I need to get data from a particular row in a text file.
eg. my text file contains the following data-

These are actually Id and Value pairs. I will be supplied the id number and have to retrive the corresponding value (say i need the value for 1003).
For a different automation tool in windows I used an excel file for the test data and could easily retieve specific values. I am wondering how to do the same for Eggplant in Windows. Please help!

You can read the file in and turn it into property list, then reference the name by the id using code like this:

Repeat with each line of file "/path/to/datafile"
	put word 1 of item 2 of it into idList.(word 1 of item 1 of it)
end repeat
put idList.(1002) // outputs Wilma in your example

I’m using “word 1 of item x” in this code as a means of stripping off any whitespace, since an item is anything between the commas in a comma-delimited file, and a word is any non-whitespace characters.

Thanks Matt… it worked for me :smiley:


I am trying to write a script for a multi-lingual application. Here is my code-

[b]Repeat with each line of file “C:\ProfileScreen_Greek.txt”
put item 2 of it into ls_StringID_String.(word 1 of item 1 of it)
end repeat

put “1170,1171,1173,1178,1179,1205” into ls_IdList
Put fun_VerifyText(ls_IdList,ls_StringID_String)

Function fun_VerifyText(ls_IdList,ls_StringID_String)
repeat with each item x of ls_IdList
put ls_StringID_String.(x) into strString
log strString
end repeat
end function[/b]

The data file ProfileScreen_Greek.txt looks like this -

1171,Μετρητής συνδεδεμένος
1205,Μάθετε περισσότερα

When I execute the script I get the error "
STUnknownMessage ERROR: No Such Function: ‘1170’
Execution Time 0:00:00 Untitled.script" on the line “put ls_StringID_String.(x) into strString
This code works perfectly if I use English alphabet characters in the data file instead of Greek or German or Dutch (basically any language that has characters which are not in the english alphabets.) Does that mean that the list ls_StringID_String cannot hold characters which are not english? In that case what is the solution? How can I pass the test data for languages other than english?

Will greatly appreciate your help. Thanks!

Answered via email, but response included here for completeness:

We think the problem is that the file isn’t/wasn’t actually being read. By default, if a file isn’t found when you try to read it (e.g., the path is wrong), eggPlant won’t say anything. If you want to change that behavior, you can put this line in your script:

set the strictFiles to true

With that value set, eggPlant will throw an exception if it doesn’t find a referenced file.

Regardless, the error that you are getting is the error that is generated if you try to refer to a key in variable that isn’t set. So the problem isn’t with the contents of the data file, it’s that the data file was never read at all.

The script in my case was able to find the file BUT Eggplant was not able to read the contents because the file contained some foreign (non english) characters (like Greek, German etc). As suggested by the Eggplant engineers, I set the “defaultStringEncoding” property at the begining of the script according to the contents of the file being read. This solved my problem. Thanks to the Eggplant Engineers :slight_smile: