Robot Framework Telnet 连接重试

Robot Framework Telnet Connection retry

有时我得到

> error: [Errno 111] Connection refused

然后我所有的测试都失败了。寻找强制 telnet 重试几次的方法。

这是我的连接命令的样子:

> Telnet.Open Connection ${IP} \ \ \ \r None

For 循环应该有效:

: FOR    ${counter}    IN RANGE     3
    \    ${success}=   Run Keyword And Return Status   Telnet.Open Connection      ${IP}
    \    Exit For Loop If   ${success}

您可以使用 Wait Until Keyword Succeeds。例如,您可以让它每 15 秒尝试一次,持续两分钟,如下所示:

Example
    Wait until keyword succeeds    2 minutes    15 seconds
    \ Telnet.Open Connection ${IP} \ \ \ \r None