selenium - 如何修复机器人框架和 seleniumlibrary 中的“不存在的设置”错误?
问题描述
我正在尝试运行一个脚本来搜索关键字“mdh”并显示 mdh.se 作为结果。我安装了机器人框架和 selenium 库,这是我用崇高文本编写并保存为 .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}
当我尝试使用机器人 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
。
设置名称和设置值之间至少需要两个空格。
推荐阅读
- sqlite - Flutter Sqlite,从数据库表中选择一个结果
- c - 选择排序未正确排序
- azure-devops - 用于 azure devops 管道构建中 API 测试的本地 SqlServer 数据库连接
- c# - 切换/加载场景时如何使用单例?
- powershell - 使用 Powershell 获取 *.lrc 以匹配它们的 *.flac 名称
- scala - spark Scala 数据框选择
- python - 错误是什么意思以及如何解决 - “ValueError:查询数据维度必须匹配训练数据维度”
- javascript - 如何在数组 JavaScript 中仅包含更新的项目
- c# - VS2019、C#、“just-my-code”和不真实的 DLL
- reactjs - axios-mock-adapter onGet 模拟数据无效