【发布时间】:2020-05-16 20:19:42
【问题描述】:
我正在使用机器人框架。谁能帮我解决下面的代码,我在运行脚本时返回错误。
我的代码是:-
[Arguments] ${CustomerName}
Sleep 4s
Set Test Variable ${counter} 24
log ${counter}
FOR ${counter} IN RANGE 9999
log ${counter}
# Scroll Element Into View //div[@tid='customerDropdown_${counter}']
Execute JavaScript document.evaluate(\"//div[@class='dropdown-menu w-100 show']/div[${counter}]\",document.body,null,9,null).singleNodeValue.scrollIntoView(true);
${present}= Run Keyword And Return Status Element Should Be Visible //div[@title='${CustomerName}']
log ${counter}
Continue For Loop If ${present} == 'false' #My Cool Keyword
Exit For Loop If ${present}
END
[参数] ${CustomerName} 睡眠 4s 设置测试变量 ${counter} 24 记录 ${计数器} 价格为 ${counter},范围为 9999 记录 ${counter}
将元素滚动到视图中 //div[@tid='customerDropdown_${counter}']
Execute JavaScript document.evaluate(\"//div[@class='dropdown-menu w-100 show']/div[${counter}]\",document.body,null,9,null).singleNodeValue.scrollIntoView(true);
${present}= Run Keyword And Return Status Element Should Be Visible //div[@title='${CustomerName}']
log ${counter}
Continue For Loop If ${present} == 'false' #My Cool Keyword
Exit For Loop If ${present}
END
出现以下错误:-
JavascriptException:消息:javascript 错误:无法读取 null 的属性“scrollIntoView”
【问题讨论】:
-
JavaScript 行有问题。尝试从非常了解 JS 的人那里获得帮助,因为这与 Robot Framework 没有任何关系。
标签: robotframework