Autofill form with 1st line of CSV, submit, then another form with 2nd line of CSV, etc

Hello and how is everyone doing?
I have a question about how to accomplish something (that isn’t clear to me from the demos and the documentation). I want to understand what order I need to put things, because the goal is to open the page, click some buttons, call the 1st line of the csv to fill certain fields, submit the form, then start a new form, but call the 2nd line of the csv file, and keep iterating. I’d like it to only go through 2 rows at first, to verify the proper functioning. I’m guessing that the “executescript_sandbox” needs to go into the subroutine but I’m not sure.

Here the order I have things now - it’s not correct obviously. Below this, I have the actual JSON, and below that I have the JSON of the subroutine.

read from the csv file
echo the status of that command
while_v2
echo the status of that command
run sub/Fillform
(this subroutine does the following:
echo Inside subroutine: Status = {!csvReadStatus}, Line = {!csvReadLineNumber}
opens the webpage
clicks a few things
types a few things
calls the csv to type {!COL1}_{!csvReadLineNumber}
types something
calls the csv to type {!COL3}_{!csvReadLineNumber}
types a couple more things
clickAndWait to click the submit button
executeScript_Sandbox return Number(${!csvReadLineNumber})+1
store true ignore error
echo reading csv file
csvRead
store false
end

Based on the “DemoCSVREadWithWhile”, I tried the following (I’ve anonymized some of the entries so I can share here :

"Commands": [
{
  "Command": "csvRead",
  "Target": "mycsvfilenamehere.csv",
  "Value": ""
},
{
  "Command": "echo",
  "Target": "Status = ${!csvReadStatus}, line = ${!csvReadLineNumber}",
  "Value": ""
},
{
  "Command": "while_v2",
  "Target": "${!csvReadStatus} == \"OK\"",
  "Value": ""
},
{
  "Command": "echo",
  "Target": "Status = ${!csvReadStatus}, line = ${!csvReadLineNumber}",
  "Value": ""
},
{
  "Command": "run",
  "Target": "sub/Fillform",
  "Value": ""
},
{
  "Command": "executeScript_Sandbox",
  "Target": "return Number(${!csvReadLineNumber})+1",
  "Value": "!csvReadLineNumber"
},
{
  "Command": "store",
  "Target": "true",
  "Value": "!errorIgnore"
},
{
  "Command": "echo",
  "Target": "Reading CSV line No.  ${!csvReadLineNumber} ",
  "Value": "!errorIgnore"
},
{
  "Command": "csvRead",
  "Target": "ReadCSVTestData.csv",
  "Value": ""
},
{
  "Command": "store",
  "Target": "false",
  "Value": "!errorIgnore"
},
{
  "Command": "end",
  "Target": "",
  "Value": ""
}
  ]
}

SUBROUTINE

    {
  "Name": "Fillform",
  "CreationDate": "2020-4-26",
  "Commands": [
    {
      "Command": "comment",
      "Target": "Subroutine for the reporter scripts",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "Inside subroutine: Status = ${!csvReadStatus}, Line = ${!csvReadLineNumber}",
      "Value": "green"
    },
    {
      "Command": "open",
      "Target": "the URL goes here",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"reporter_type\"]/li[1]/div/label/span",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "id=type_of_issue_digital",
      "Value": ""
    },
    {
      "Command": "type",
      "Target": "id=type_of_issue_digital",
      "Value": "Digital goods"
    },
    {
      "Command": "type",
      "Target": "id=fullname_input_text",
      "Value": "my name goes here"
    },
    {
      "Command": "type",
      "Target": "id=email",
      "Value": "jedevita@netflix.com"
    },
    {
      "Command": "type",
      "Target": "id=phone_number",
      "Value": "000-000-0000"
    },
    {
      "Command": "type",
      "Target": "id=tm_holder_name",
      "Value": "company name goes here"
    },
    {
      "Command": "type",
      "Target": "id=reported_username",
      "Value": "${!COL1}_${!csvReadLineNumber}"
    },
    {
      "Command": "type",
      "Target": "id=description",
      "Value": "description goes here"
    },
    {
      "Command": "type",
      "Target": "id=link_to_tweet",
      "Value": "${!COL3}_${!csvReadLineNumber}"
    },
    {
      "Command": "type",
      "Target": "id=disclaimer_third_parties",
      "Value": "disclaimer_third_parties"
    },
    {
      "Command": "type",
      "Target": "id=disclaimer_accuracy",
      "Value": "disclaimer_accuracy"
    },
    {
      "Command": "type",
      "Target": "id=disclaimer_good_faith",
      "Value": "disclaimer_good_faith"
    },
    {
      "Command": "clickAndWait",
      "Target": "id=submit_button",
      "Value": ""
    }
  ]
}

No problem you need to change this value ${!csvReadLineNumber} with correct line of csv to use or use new command csvReadArray

Here info
https://ui.vision/rpa/docs/selenium-ide/csvread

Thank you! I’m sorry but I’m very new to Selenium. I don’t know how to use the array function yet, so I’d like to try to stick with csvread for now. But if I may ask a clarifying question? I think the first line “csvrRead” is correct, it grabs the first line in the csv, then calls the subroutine and submits. But what do I do next to iterate?

I’m guessing after the run command, that the next lines should be:

executeScript_Sandbox // return Number(${!csvReadLineNumber})+1
store true !errorIgnore
run sub/Fillform
etc…

Am I getting closer?

this is very confusing to me. I’m sorry if it should be obvious. I appreciate your help!

You must study ui vision RPA to create a good macro

To change the csv line you can add this command inside your macro

   {
      "Command": "store",
      "Target": "2",
      "Value": "!csvReadLineNumber"
    },

2 is the second line of csv you can change with your prefered line number

1 Like

Thanks. I’ll keep studying this but I’ve broken it. now it’s appending the line #2 and adding it to the end of the entry from column 4, which breaks the script.

Utterly lost now.

When do I use command store? before or after csvRead?

should line 1 read:
csvRead

You must add before csvread to set the csv line to read

1 Like

Thank you. That makes sense. I think the store command is making this more confusing. Instead I will import a csv with only 2 rows, to start with. So! Here is my remaining question:

I still don’t understand what these “echo” and “while_v2” and executeScript sandbox commands are for, and what order they need to appear in to achieve my goal or if they are even necessary.

The reason for my confusion is that the demo for
“demoCsvReadWithWhile” assumes a goal of filling a single form with several rows from the csv.

My goal is different: I want to fill a form with row 1 of csv, submit it, and then do another form that pulls row 2 and submits it, and so on.

I am hoping for your patience with my last question before I give up because there is no documentation for my goal. Can you suggest changes I must make to the macro and the sub routine? Many thanks, I appreciate your help.

Macro
{
“Name”: “Reporter”,
“CreationDate”: “2020-4-26”,
“Commands”: [
{
“Command”: “csvRead”,
“Target”: “5tweets.csv”,
“Value”: “”
},
{
“Command”: “echo”,
“Target”: “Status = ${!csvReadStatus}, line = ${!csvReadLineNumber}”,
“Value”: “”
},
{
“Command”: “while_v2”,
“Target”: “${!csvReadStatus} == "OK"”,
“Value”: “”
},
{
“Command”: “run”,
“Target”: “sub/Fillform”,
“Value”: “”
},
{
“Command”: “echo”,
“Target”: “Status = ${!csvReadStatus}, line = ${!csvReadLineNumber}”,
“Value”: “”
},
{
“Command”: “executeScript_Sandbox”,
“Target”: “return Number(${!csvReadLineNumber})+1”,
“Value”: “!csvReadLineNumber”
},
{
“Command”: “store”,
“Target”: “true”,
“Value”: “!errorIgnore”
},
{
“Command”: “echo”,
“Target”: "Reading CSV line No. ${!csvReadLineNumber} ",
“Value”: “!errorIgnore”
},
{
“Command”: “run”,
“Target”: “sub/Fillform”,
“Value”: “”
},
{
“Command”: “csvRead”,
“Target”: “ReadCSVTestData.csv”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “false”,
“Value”: “!errorIgnore”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”
}
]
}

SUBROUTINE HERE
{
“Name”: “Fillform”,
“CreationDate”: “2020-4-26”,
“Commands”: [
{
“Command”: “comment”,
“Target”: “Subroutine for the reporter script”,
“Value”: “”
},
{
“Command”: “comment”,
“Target”: “echo // Inside subroutine: Status = ${!csvReadStatus}, Line = ${!csvReadLineNumber}”,
“Value”: “green”
},
{
“Command”: “open”,
“Target”: “https://formURLhere.com”,
“Value”: “”
},
{
“Command”: “click”,
“Target”: “xpath=//*[@id="reporter_type"]/li[1]/div/label/span”,
“Value”: “”
},
{
“Command”: “click”,
“Target”: “id=type_of_issue_digital”,
“Value”: “”
},
{
“Command”: “type”,
“Target”: “id=fullname_input_text”,
“Value”: “myname”
},
{
“Command”: “type”,
“Target”: “id=email”,
“Value”: “me@myemail.com
},
{
“Command”: “type”,
“Target”: “id=phone_number”,
“Value”: “3105551212”
},
{
“Command”: “type”,
“Target”: “id=tm_holder_name”,
“Value”: “companyname”
},
{
“Command”: “type”,
“Target”: “id=reported_username”,
“Value”: “${!COL1}${!csvReadLineNumber}"
},
{
“Command”: “type”,
“Target”: “id=description”,
“Value”: “Selling bad accounts”
},
{
“Command”: “type”,
“Target”: “id=link_to_tweet”,
“Value”: "${!COL3}
${!csvReadLineNumber}”
},
{
“Command”: “click”,
“Target”: “id=disclaimer_third_parties”,
“Value”: “”
},
{
“Command”: “comment”,
“Target”: “type // id=disclaimer_third_parties”,
“Value”: “disclaimer_third_parties”
},
{
“Command”: “click”,
“Target”: “id=disclaimer_accuracy”,
“Value”: “”
},
{
“Command”: “comment”,
“Target”: “type // id=disclaimer_accuracy”,
“Value”: “disclaimer_accuracy”
},
{
“Command”: “click”,
“Target”: “id=disclaimer_good_faith”,
“Value”: “”
},
{
“Command”: “comment”,
“Target”: “type // id=disclaimer_good_faith”,
“Value”: “disclaimer_good_faith”
},
{
“Command”: “clickAndWait”,
“Target”: “id=submit_button”,
“Value”: “”
}
]
}

Your work is easy to do but you can not copy a demo macro because every macro must create custom, your code is the macro demo and is not the best for your case.

I create for me custom macro to login in more and more sites withourt any errors but i do not copy the macro demo I create my macro with command i need.

Your is a demo macro code and it’s not the best for your work, try to create a custom macro.