无论如何,是否可以在没有.robot/.txt脚本的情况下运行机器人框架,还是可以从某些数据中生成.robot/.txt文件?
有什么方法可以使用代码或JSON而不是.Orobot文件运行机器人框架?还是我应该先生成一个.robot文件然后运行?我不确定是否有更好的方法来执行此操作,因为某些步骤取决于上述步骤的输出(Unitsest/Pytest不支持这一点)。
例如,我有JSON中的测试序列列表
{
"seq_id": 1,
"seq_type": 1, # normal, flag
"seq_len": 1, # 1 for normal, n for flag
"flag_data": {
"flag_name": "",
"flag_type": "", # if/else, for, while with steps block
"flag_length": 1,
# flag_type-if
"mid_val": 1, # variable
"comparison_left_type": '>', # > >= empty
"comparison_left_var": 1, # variable or constant
"comparison_right_type": '<', # > >= empty
"comparison_right_var": 1, # variable or constant
# flag_type-else
# flag_type-for
"loop_length": 1, # variable or constant
# flag_type-while
# "mid_val": 1, # variable
# "comparison_left_type": '>', # > >= empty
# "comparison_left_var": 1, # variable or constant
# "comparison_right_type": '<', # > >= empty
# "comparison_right_var": 1, # variable or constant
},
"sequence_data": [{
"step_name": 'step_1',
"step_type": '', # a embedded function to be used in function library
"step_variable_a": a
"step_variable_b": b
}]
}
Is there any way to run robot framework with a code or json instead of .robot file? Or should I generate a .robot file first and then run? I am unsure if there is a better way to do this, since some of the steps depend on previous steps' output (unittest/pytest does not support this).
I have a list of test sequences in json, for example
{
"seq_id": 1,
"seq_type": 1, # normal, flag
"seq_len": 1, # 1 for normal, n for flag
"flag_data": {
"flag_name": "",
"flag_type": "", # if/else, for, while with steps block
"flag_length": 1,
# flag_type-if
"mid_val": 1, # variable
"comparison_left_type": '>', # > >= empty
"comparison_left_var": 1, # variable or constant
"comparison_right_type": '<', # > >= empty
"comparison_right_var": 1, # variable or constant
# flag_type-else
# flag_type-for
"loop_length": 1, # variable or constant
# flag_type-while
# "mid_val": 1, # variable
# "comparison_left_type": '>', # > >= empty
# "comparison_left_var": 1, # variable or constant
# "comparison_right_type": '<', # > >= empty
# "comparison_right_var": 1, # variable or constant
},
"sequence_data": [{
"step_name": 'step_1',
"step_type": '', # a embedded function to be used in function library
"step_variable_a": a
"step_variable_b": b
}]
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您需要运行机器人框架,但不能在.robot文件中运行,则可以在Python中运行。
或者,如果要读取此JSON文件,则可以在Python中创建一个函数,或在Robot框架中搜索库JSON以读取此JSON文件并在字典中转换,以使JSON文件中的信息工作。
在Python中的字典中读取和转换此JSON文件的一个示例:
您无法运行.py或.robot Archives之类的JSON文件,因为将.json文件用于信息。
If you need to run Robot Framework but not in .robot file, you can run in Python instead.
Or if you want to read this json file, you can create a function in Python or search a Library Json in Robot Framework to use for read this json file and transform in dictionary to work whit the information inside of your json file.
A example of read and transform this json file in dictionary in Python:
You cannot run a json file like .py or .robot archives, because .json files is made to use for information.