我正在尝试运行脚本来搜索关键字“mdh”并显示 mdh.se 作为结果。 我安装了机器人框架和 selenium 库,这是我用 sublime text 编写并保存为 .robot 文件的脚本。
*** Settings ***
Library Selenium2Library
Suite Setup Go to homepage
Suite Teardown Close All Browsers
*** Variables ***
${HOMEPAGE} http://www.google.com
${BROWSER} chrome
*** Test Cases ***
Google mdh and find mdh
Google and check results mdh www.mdh.se
*** Keywords ***
Google and check results
[Arguments] ${searchkey} ${result}
Input Text class_name=gLFyf gsfi ${searchkey}
Click Button class_name=Tg7LZd
Wait Until Page Contains ${result}
Go to homepage
Open Browser ${HOMEPAGE} ${BROWSER}
当我尝试使用 robots mdh.robot 运行脚本时,它显示有 5 个错误。
C:\Users\malvi\Desktop>robot mdh.robot
[ ERROR ] Error in file 'C:\Users\malvi\Desktop\mdh.robot': Non-existing setting 'Library
Selenium2Library'.
[ ERROR ] Error in file 'C:\Users\malvi\Desktop\mdh.robot': Non-existing setting 'Suite Setup Go to
homepage'.
[ ERROR ] Error in file 'C:\Users\malvi\Desktop\mdh.robot': Non-existing setting 'Suite Teardown
Close All Browsers'.
[ ERROR ] Error in file 'C:\Users\malvi\Desktop\mdh.robot': Setting variable '${HOMEPAGE}
http://www.google.com' failed: Invalid variable name '${HOMEPAGE} http://www.google.com'.
[ ERROR ] Error in file 'C:\Users\malvi\Desktop\mdh.robot': Setting variable '${BROWSER} chrome'
failed: Invalid variable name '${BROWSER} chrome'.
我做错了什么吗?
最佳答案
仔细阅读错误消息,并按字面意思理解。据说没有名为 Suite Setup Go to homepage
的设置,这是一个真实的说法。不过,有一个名为 Suite Setup
的设置。
设置名称和设置值之间至少需要两个空格。
关于selenium - 如何修复来自robotframework和seleniumlibrary的 "Non-existing setting"错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59010766/