Open URL from CSV - peform actions - close & loop to end of CSV

I have a script like below that pulls urls from this file ‘test brand update for ui vision.csv’

The script seems to work but how do i make it continue until its done every url from the CSV file. It currently completes one then stops.

P.s this is my first every script so please be gentle

thanks !

{
  "Name": "New Test",
  "CreationDate": "2024-7-25",
  "Commands": [
    {
      "Command": "csvRead",
      "Target": "test brand update for ui vision.csv",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "open",
      "Target": "${!COL1}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "selectWindow",
      "Target": "tab=open",
      "Value": "${!COL1}",
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"Basic information\"]/div/div",
      "Value": "",
      "Targets": [
        "xpath=//*[@id=\"Basic information\"]/div/div",
        "xpath=//form/div/div/div",
        "css=#Basic information > div > div.w-full"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"preview-product-brand\"]/div[2]/div/div/div/span/span/input",
      "Value": "",
      "Targets": [
        "xpath=//*[@id=\"preview-product-brand\"]/div[2]/div/div/div/span/span/input",
        "xpath=//div[2]/div/div/div/span/span/input",
        "css=#preview-product-brand > div.flex.relative > div > div > div > span > span > input"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"theme-arco-select-popup-0\"]/div/div/li[2]/div/div/div",
      "Value": "",
      "Targets": [
        "xpath=//*[@id=\"theme-arco-select-popup-0\"]/div/div/li[2]/div/div/div",
        "xpath=//li[2]/div/div/div",
        "css=#theme-arco-select-popup-0 > div > div > li.theme-arco-select-option.theme-m4b-select-option.theme-arco-select-option-hover.flex > div > div > div"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"GEC-main\"]/div[2]/div/div/div/div[2]/div[3]/button/span",
      "Value": "",
      "Targets": [
        "xpath=//*[@id=\"GEC-main\"]/div[2]/div/div/div/div[2]/div[3]/button/span",
        "xpath=//button/span",
        "css=#GEC-main > div.flex.flex-col.mx-auto.h-full > div.w-full.pt-16.sticky > div > div > div.theme-arco-space.theme-arco-space-horizontal.theme-arco-space-align-center.theme-m4b-space > div:nth-child(3) > button > span"
      ],
      "Description": ""
    },
    {
      "Command": "click",
      "Target": "xpath=/html/body/div[11]/div[2]/div/div[2]/div[3]/div/button[2]/span",
      "Value": "",
      "Targets": [
        "xpath=/html/body/div[11]/div[2]/div/div[2]/div[3]/div/button[2]/span",
        "xpath=//button[2]/span",
        "css=body > div:nth-child(20) > div.theme-arco-modal-wrapper.theme-arco-modal-wrapper-align-center > div > div:nth-child(2) > div.theme-arco-modal-footer > div > button.theme-arco-btn.theme-arco-btn-primary.theme-arco-btn-size-large.theme-arco-btn-shape-square > span"
      ],
      "Description": ""
    }
  ]
}

Using my good friend chatgpt i have been able to get it to loop but it always just loops the first url from the CSV over and over :frowning:

{
  "Name": "New Test",
  "CreationDate": "2024-7-25",
  "Commands": [
    {
      "Command": "csvRead",
      "Target": "test brand update for ui vision.csv",
      "Value": "",
      "Description": "Read CSV file"
    },
    {
      "Command": "label",
      "Target": "start",
      "Value": "",
      "Description": "Start label for loop"
    },
    {
      "Command": "store",
      "Target": "true",
      "Value": "continueLoop",
      "Description": "Initialize loop condition"
    },
    {
      "Command": "gotoIf",
      "Target": "${continueLoop} == false",
      "Value": "end",
      "Description": "Exit loop if no more rows"
    },
    {
      "Command": "csvRead",
      "Target": "test brand update for ui vision.csv",
      "Value": "",
      "Description": "Read CSV row"
    },
    {
      "Command": "gotoIf",
      "Target": "${!csvReadStatus} == 'EOF'",
      "Value": "end",
      "Description": "Exit loop if end of CSV"
    },
    {
      "Command": "open",
      "Target": "${!COL1}",
      "Value": "",
      "Description": "Open URL from CSV"
    },
    {
      "Command": "selectWindow",
      "Target": "tab=open",
      "Value": "${!COL1}",
      "Description": "Select the opened window"
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"Basic information\"]/div/div",
      "Value": "",
      "Targets": [
        "xpath=//*[@id=\"Basic information\"]/div/div",
        "xpath=//form/div/div/div",
        "css=#Basic information > div > div.w-full"
      ],
      "Description": "Click Basic Information"
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"preview-product-brand\"]/div[2]/div/div/div/span/span/input",
      "Value": "",
      "Targets": [
        "xpath=//*[@id=\"preview-product-brand\"]/div[2]/div/div/div/span/span/input",
        "xpath=//div[2]/div/div/div/span/span/input",
        "css=#preview-product-brand > div.flex.relative > div > div > div > span > span > input"
      ],
      "Description": "Click Brand Input"
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"theme-arco-select-popup-0\"]/div/div/li[2]/div/div/div",
      "Value": "",
      "Targets": [
        "xpath=//*[@id=\"theme-arco-select-popup-0\"]/div/div/li[2]/div/div/div",
        "xpath=//li[2]/div/div/div",
        "css=#theme-arco-select-popup-0 > div > div > li.theme-arco-select-option.theme-m4b-select-option.theme-arco-select-option-hover.flex > div > div > div"
      ],
      "Description": "Select Brand"
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"GEC-main\"]/div[2]/div/div/div/div[2]/div[3]/button/span",
      "Value": "",
      "Targets": [
        "xpath=//*[@id=\"GEC-main\"]/div[2]/div/div/div/div[2]/div[3]/button/span",
        "xpath=//button/span",
        "css=#GEC-main > div.flex.flex-col.mx-auto.h-full > div.w-full.pt-16.sticky > div > div > div.theme-arco-space.theme-arco-space-horizontal.theme-arco-space-align-center.theme-m4b-space > div:nth-child(3) > button > span"
      ],
      "Description": "Click Submit"
    },
    {
      "Command": "click",
      "Target": "xpath=/html/body/div[11]/div[2]/div/div[2]/div[3]/div/button[2]/span",
      "Value": "",
      "Targets": [
        "xpath=/html/body/div[11]/div[2]/div/div[2]/div[3]/div/button[2]/span",
        "xpath=//button[2]/span",
        "css=body > div:nth-child(20) > div.theme-arco-modal-wrapper.theme-arco-modal-wrapper-align-center > div > div:nth-child(2) > div.theme-arco-modal-footer > div > button.theme-arco-btn.theme-arco-btn-primary.theme-arco-btn-size-large.theme-arco-btn-shape-square > span"
      ],
      "Description": "Confirm Submit"
    },
    {
      "Command": "csvRead",
      "Target": "test brand update for ui vision.csv",
      "Value": "",
      "Description": "Read next row"
    },
    {
      "Command": "gotoIf",
      "Target": "${!csvReadStatus} == 'EOF'",
      "Value": "end",
      "Description": "Exit loop if end of CSV"
    },
    {
      "Command": "gotoLabel",
      "Target": "start",
      "Value": "",
      "Description": "Go to start label for next row"
    },
    {
      "Command": "label",
      "Target": "end",
      "Value": "",
      "Description": "End label for loop"
    }
  ]
}

Ok seems you just need to use play loop

Dont need any support now leaving this hear in case anyone else finds it helpful

1 Like