robotframework 执行Input Text卡住(Input Text输入超长文本)

背景:

测试需要验证超长字符串,结果在执行测试中发现卡在Input Text关键字,发现Input Text在输入超长字符串时有问题字。

Input Text    ${selector}    ${超长字符串}

解决方法:

执行Javascript脚本输入超长文字,其中${selector}和${超长字符串}

Execute JavaScript    document.querySelector('${selector}').value = "${超长字符串}";

执行脚本之后还要触发input事件才算完成输入:

Execute JavaScript    var event = new Event('input', { bubbles: true }); document.querySelector('${selecotr}').dispatchEvent(event)

另外遇到了一个错误:

JavascriptException: Message: javascript error: Unexpected identifier 'and'
我的查询条件是一个sql语句,因此里面含有and,直接使用Execute JavaScript输入文字时报了上面的错误,因此执行前先将该字符串设置成变量

${query_sql}=    Set Variable    ${含有and的超长字符串}

posted @ 2025-06-16 10:23  水库浪子9527  阅读(2)  评论(0)    收藏  举报  来源