Hello Guys,
I have been working on a task to take input values from csv and go to the website of bluedart and track the status of the shipment.Below is the code for the task
{
"Name": "bluedart_shipment_status",
"CreationDate": "2023-3-20",
"Commands": [
{
"Command": "csvReadArray",
"Target": "shipment.csv",
"Value": "file",
"Description": ""
},
{
"Command": "executeScript_Sandbox",
"Target": "return ${!CsvReadMaxRow};",
"Value": "row",
"Description": ""
},
{
"Command": "executeScript_Sandbox",
"Target": "return ${file[0]}.length;",
"Value": "col",
"Description": ""
},
{
"Command": "comment",
"Target": "Define array",
"Value": "\"\"",
"Description": ""
},
{
"Command": "executeScript_Sandbox",
"Target": "var arr = []; for(var x = 0; x < 5; x++){arr[x] = []; for(var y = 0; y < 3; y++){arr[x][y] = (x+1)*(y+1);}}; return arr",
"Value": "array1",
"Description": ""
},
{
"Command": "comment",
"Target": "loop over all CSV values",
"Value": "",
"Description": ""
},
{
"Command": "forEach",
"Target": "file",
"Value": "row",
"Description": ""
},
{
"Command": "echo",
"Target": "col1=${row[0]}, col2=${row[1]}, col3=${row[2]}",
"Value": "brown",
"Description": ""
},
{
"Command": "open",
"Target": "https://bluedart.com/",
"Value": "",
"Description": ""
},
{
"Command": "click",
"Target": "id=trackingNoTrackDart",
"Value": "",
"Targets": [
"id=trackingNumber",
"name=trackingNumber",
"xpath=//*[@id=\"trackingNumber\"]",
"xpath=//textarea[@id='trackingNumber']",
"xpath=//textarea",
"css=#trackingNumber"
],
"Description": ""
},
{
"Command": "type",
"Target": "id=trackingNoTrackDart",
"Value": "${row[1]}",
"Targets": [
"id=trackingNumber",
"name=trackingNumber",
"xpath=//*[@id=\"trackingNumber\"]",
"xpath=//textarea[@id='trackingNumber']",
"xpath=//textarea",
"css=#trackingNumber"
],
"Description": ""
},
{
"Command": "clickAndWait",
"Target": "id=goBtnTrackDart",
"Value": "",
"Targets": [
"id=goBtnTrackDart",
"xpath=//*[@id=\"goBtnTrackDart\"]",
"xpath=//input[@id='goBtnTrackDart']",
"xpath=//p/input",
"css=#goBtnTrackDart"
],
"Description": ""
},
{
"Command": "click",
"Target": "linkText=Status and Scan",
"Value": "",
"Targets": [
"linkText=Status and Scan",
"xpath=//*[@id=\"AWB58810217196\"]/div/div[2]/div/div/ul/li[2]/a",
"xpath=//div/div/ul/li[2]/a",
"css=#AWB58810217196 > div > div:nth-child(2) > div > div > ul > li:nth-child(2) > a"
],
"Description": ""
},
{
"Command": "storeText",
"Target": "xpath=//*[@id=\"SCAN${row[1]}\"]/div/table/tbody/tr/td[2]",
"Value": "text",
"Description": ""
},
{
"Command": "store",
"Target": "0",
"Value": "i",
"Description": ""
},
{
"Command": "executeScript_Sandbox",
"Target": "var newArr = ${array1}; newArr[${i}][0] = \"Bluedart\"; newArr[${i}][1] = ${row[1]}; newArr[${i}][2] = ${text}; return newArr",
"Value": "text",
"Description": ""
},
{
"Command": "executeScript",
"Target": "return Number (${i}) + 1",
"Value": "i",
"Description": ""
},
{
"Command": "echo",
"Target": "${text}",
"Value": "",
"Description": ""
},
{
"Command": "csvSaveArray",
"Target": "array1",
"Value": "BD_output.csv",
"Description": ""
},
{
"Command": "end",
"Target": "",
"Value": "",
"Description": ""
}
]
}
My issue is when i run the script after the end of the for loop i think it re-runs the script from the start and array values are returned to its original state.Below is the output of the csv file at the end of script.