[BUG] Multiple CSV Files With While Not Working

data-driven-testing
csv

#1

Hi everyone!

Introduction
I think I found a bug. This is a simple CSV read I’m working on with two CSV files:

  1. testsonly-variables.csv: Saves the last read line for a persistent loop in case the macro stops running.

  2. testsonly-file.csv: A list of a few websites I want to work with.

Issue
The following code ALWAYS read the last line on the first loop of the while. From the second loop and beyond, it reads correctly.

Store | ${startpage} | !csvReadLineNumber

Expected Behavior
At _Store | {startpage} | !csvReadLineNumber_ it should read the line I give it. If I put the number '10' instead of {startpage}, it should read the line 10 not the last one in the first loop.

How to Test It
The code is well documented with “comment” and “echo” commands. You can reproduce the bug yourself by following the steps:

  1. Download .JSON code. https://pastebin.com/a6s0KMPt
  2. Create testsonly-variables.csv CSV file. https://pastebin.com/yScLjekn
  3. Create testsonly-file.csv CSV file. https://pastebin.com/nRa1Xftt
  4. Hit “play macro”.

If anyone has any ideas/workarounds for it I’m very thankful :slight_smile:


#2

The following code ALWAYS read the last line on the first loop of the while.

Well, I think this is because you have this line in front of csvRead:

{
“Command”: “store”,
“Target”: “${!csvReadMaxRow}”,
“Value”: “!csvReadLineNumber”
},

If you remove it, it should work :wink:


#3

Oh. Silly me.

Thank you very much :slight_smile:


#4

Precisava ler o primeiro arquivo (cnpj.csv), pegar a ULTIMA linha e por na variável id=cnpj.
Também precisava fazer o mesmo com o segundo arquivo (email.csv) e por na variável id=email.
Alguem consegue me ajudar? Pode escrever em ingles que traduzo no google :joy::joy:
{
“Command”: “csvRead”,
“Target”: “cnpj.csv”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “{!csvReadMaxRow}", "Value": "!csvReadLineNumber" }, { "Command": "csvRead", "Target": "cnpj.csv", "Value": "" }, { "Command": "type", "Target": "id=cnpj", "Value": "{!COL1}”
},
{
“Command”: “pause”,
“Target”: “1000”,
“Value”: “”
},
{
“Command”: “csvRead”,
“Target”: “email.csv”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “${!csvReadMaxRow}”,
“Value”: “!csvReadLineNumber”
},

{
  "Command": "csvRead",
  "Target": "email.csv",
  "Value": ""
},

{
  "Command": "type",
  "Target": "id=email",
  "Value": "${!COL1}"
}