Loading variables from csv file

I tried to put all variables for different test cases into 1 csv with different variable names. It was a single username and password for each test case. In each test case, I call loadVars with the filename at the beginning and at the end of the test case, I call endLoadVars. The first test case runs fine. The second test case runs fine but then it tries to run again with blank username but the password is filled in. I also tried to put the variables into separate files. I saw the same behavior.

Hey @glenn_remar,
Can you share your saved file and your csv file?

I removed url and username and passwords. I could combine 2 users into one file to see if that fixes but they go to different websites after logging in. This works for the first test case for the first user. For the second test, it works for the second user but then tries to go in again with no username and repeats the password. I am using different csv files and different variable names but otherwise the steps are the same.

loadVars|env.csv
open|url
type|id=userNameInputBox|${APP_USERNAME}
type|id=passwordInputBox|${APP_PASSWORD}
click|id=_cbdLogOnOff
endLoadVars

where url is the url to the site.

env.csv
APP_USERNAME,APP_PASSWORD
NotMyUserName,NotMyPassword

Hi @glenn_remar, It would be great if you can upload the files since it would help us reproduce this issue faster! You can send it in a private topic to me and @tientt1938 if you’re not comfortable with sharing data publicly.

I will make sure that the issue somewhere else in the recording. And I will see if I can reproduce with information that is public.

I cannot share krecorder files or zip file from work. But here is example. Can loadVars not run just once or do I not understand how to supply variables in csv file?

I have one variable with 1 instance. But it actually went through script twice. Second time variable was empty.

I can recreate at home and post if you cannot see.

google1.csv
FIRST_SEARCH_TERM
Katalon

Hi @glenn_remar,
Make sure that there isn’t an empty line at the end of the CSV file.
Otherwise, that empty line will be counted as a legal value for column FIRST_SEARCH_TERM

I looked at the file in editor that shows new line characters. There is not an extra row.

image

You need to use Notepad or other text editor to open, delete blank lines and save, this will not happen

1 Like

I found that the last line of the csv file cannot have a CRLF. I removed the last carriage return after Katalon above and the test only ran once, not twice.

1 Like