提问人:Jimmy 提问时间:3/28/2022 最后编辑:Jimmy 更新时间:3/29/2022 访问量:220
robotframework:无法找到文件夹外的关键字
robotframework : failed to locate keywords outside the folder
问:
folder structure
Project
|
|_ _folder1 (abc.robot)
|
|_ _folder2 (def.robot)
| |_ _ folder3 (ghi.robot)
|
|
|
setup.robot
文件夹 1 abc.robot 内部
#abc.robot
#create session api call
*** Settings ***
Library RequestsLibrary
Resource /setup.robot
Post_new_user
create session newsession ${url}
${body}= create dictionary mobile_prefix=${mobile_prefix} mobile_number=${mobile_number}
${headers}= create dictionary Content-Type=application/json
${response}= post request newsession newuser/register data=${body} headers=${headers}
#validations
${status_code}= convert to string ${response.status_code}
should be equal ${status_code} 200
在文件夹2 def.robot
#def.robot
#test data driven with robot
*** Settings ***
Resource ../../ghi.robot
Test Template Registration Test
*** Test Cases ***
test1 +12 9999999991
test2 +12 9999999992
test3 +12 9999999993
*** Keywords ***
Registration Test
[Arguments] ${mobile_prefix} ${mobile_number}
a mobile prefix ${mobile_prefix}
a mobile number ${mobile_number}
Post_new_user
文件夹内3
#ghi.robot
#set of keywords / steps to call
*** Keywords ***
a mobile prefix ${mobile_prefix}
set test variable ${mobile_prefix} ${mobile_prefix}
a mobile number ${mobile_number}
set test variable ${mobile_number} ${mobile_number}
step.机器人
*** Variable ***
${url}= https://example/com
使用机器人框架的测试数据驱动程序 但是当 def.robot 运行时 文件的位置总是有问题
- 资源文件“\setup.robot”不存在。
- 资源文件“ghi.robot”不存在。
- 未找到名称为“a mobile prefix ${mobile_prefix}”的关键字。
我错过了什么吗?
答:
0赞
Vyacheslav
3/29/2022
#1
#abc.robot
...
Resource ../setup.robot
#def.robot
...
Resource ./folder3/ghi.robot
评论
0赞
Jimmy
3/30/2022
单“.”和双“..”有区别吗?
0赞
Vyacheslav
3/30/2022
..是父文件夹,但 .是当前文件夹
0赞
Vyacheslav
3/31/2022
@ningpra 你试过我的解决方案吗?
评论
Resource ../setup.robot
Resource ../../folder2/folder3/ghi.robot