How to resume kantu from where it left off if it lost connection with db?


#1

Say there is db of student profiles. Our servers suck and lose connection quite often.
my pseudocode:

process student profile
if
textpresent - “400”, or “not found” or “page unavailable”
find last id, start from it
endif

How do I do this?

1)store the variable of last current id
2) check if the text “connection lost” is present and log in\refresh again
3) input login , pwd
4)start with last id?


Incomplete automation of 2 clicks&save button in kantu, need to insert COL1 in html link from CSV table,need help
#2

Hi! That is an interesting question!

I think your proposed solution “store the variable of last current id” is exactly right. And the way to do this is to use a global variable.

I modified the DemoCsvReadWithWhile accordingly. The new code is marked with red. Now, you can stop the macro and restart it, and it will continue with last line that was not yet submitted (= the macro start and stop “simulates” the unreliable website in your case). The global var is used to set !csvReadLineNumber to the right value (= the line number to read).

Just one thing to note, before running the main macro, you need to run this one line macro here once, so that the global variable is defined:

{
  "CreationDate": "2018-9-17",
  "Commands": [
    {
      "Command": "store",
      "Target": "0",
      "Value": "GLOBAL_LAST_LINE_READ"
    }
  ]
}

Main macro:
{
“CreationDate”: “2018-9-17”,
“Commands”: [
{
“Command”: “store”,
“Target”: “180”,
“Value”: “!timeout_macro”
},
{
“Command”: “store”,
“Target”: “fast”,
“Value”: “!replayspeed”
},
{
“Command”: “comment”,
“Target”: “Add resume feature”,
“Value”: “”
},
{
“Command”: “if”,
“Target”: “${global_last_line_read} > 0”,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “${global_last_line_read} “,
“Value”: “!csvReadLineNumber”
},
{
“Command”: “endif”,
“Target”: “”,
“Value”: “”
},
{
“Command”: “comment”,
“Target”: “The file ReadCSVTestData.csv is pre-installed with Kantu.”,
“Value”: “”
},
{
“Command”: “csvRead”,
“Target”: “ReadCSVTestData.csv”,
“Value”: “”
},
{
“Command”: “echo”,
“Target”: “Status = ${!csvReadStatus}, line = ${!csvReadLineNumber}”,
“Value”: “”
},
{
“Command”: “while”,
“Target”: “”${!csvReadStatus}” == “OK””,
“Value”: “”
},
{
“Command”: “store”,
“Target”: “${!csvReadLineNumber}”,
“Value”: “global_last_line_read”
},
{
“Command”: “echo”,
“Target”: “status = ${!csvReadStatus}, line = ${!csvReadLineNumber}”,
“Value”: “”
},
{
“Command”: “open”,
“Target”: “https://docs.google.com/forms/d/e/1FAIpQLScGWVjexH2FNzJqPACzuzBLlTWMJHgLUHjxehtU-2cJxtu6VQ/viewform”,
“Value”: “”
},
{
“Command”: “type”,
“Target”: “name=entry.933434489”,
“Value”: “${!COL1}_${!csvReadLineNumber}”
},
{
“Command”: “type”,
“Target”: “name=entry.2004105717”,
“Value”: “${!COL2}”
},
{
“Command”: “type”,
“Target”: “name=entry.1382578664”,
“Value”: “${!COL3}”
},
{
“Command”: “clickAndWait”,
“Target”: “//*[@id=“mG61Hd”]/div/div[2]/div[3]/div[1]/div/div/content/span”,
“Value”: “”
},
{
“Command”: “storeEval”,
“Target”: “${!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”: “endWhile”,
“Target”: “”,
“Value”: “”
}
]
}


How to random select csv value