Basically as the error reads, Its saying it doesn’t contain key ‘1’
Which ${element} will in your case equal either 1 or a number from that upto your list count+1 variable you’ve provided (your examples above don’t show the value assigned to these or how the count is returned) the line from above:
FOR ${element} IN RANGE 1 ${total_list_count}+1
as that’s the value your giving the kw to get from the dictionary:
${key}= Get From Dictionary ${text_dict} ${element}
for which if there’s no matching key when using the Get From Dictionary it will fail, unless you use a default as per usings for that keyword.
If you wanted to keep to getting by index then you could use the Get Dictionary Keys to get all keys, and then use Get From List keyword to get the key by index? both keywords are from the collections library, and then you could use the Get From Dictionary by passing in the return value (key) returned from Get From List, assuming getting by index is what you were trying to do, I’m sure you can also use the Evaluate keyword in a much cleaner way (don’t use it often and away from my computer to give you a proper example)
Note, Get From List will be 0 indexed.
Definitely worth considering a default on Get From Dictionary for cases it may not exists and handling that, without knowing/seeing more.
Worthy mention: Support for default
is new in Robot Framework 6.0.
Hope that helps anyways (:
NOTE: Log and Log To Console are very good ways of debugging between statements, to full understanding the happenings to why sometimes you might get unexpected results, while testing your own code.