首页 > 解决方案 > 如何修复机器人框架和 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'.

难道我做错了什么?

标签: seleniumtestingautomated-testsrobotframework

解决方案


仔细阅读错误消息,并按字面意思理解。这是说没有设置命名Suite Setup Go to homepage,这是一个真实的陈述。但是,有一个名为 的设置Suite Setup

设置名称和设置值之间至少需要两个空格。


推荐阅读