机器人框架数据驱动场景的 JSON 格式

Posted

技术标签:

【中文标题】机器人框架数据驱动场景的 JSON 格式【英文标题】:JSON Formatting for Robot Framework Data Driven Scenario 【发布时间】:2022-01-06 18:48:27 【问题描述】:

我找到了很多关于 JSON 格式的教程,但找不到我的 JSON 的问题。 谁能看一下,告诉我哪里坏了?

目标是提供 3 种不同的场景,用户根据 3 个敏锐度部门之一选择测试答案。

每个视力部分有4个小节,每个小节都有自己的答案。

"acuity1":
    "sec1":
               
        "ans1": "\ue01b",
         "ans2":"\ue01b",
         "ans3": "\ue01b",
         "ans4": "\ue01b",
         "ans5": "\ue01b",
         "ans6": "\ue01b",
         "ans7": "\ue01b",
         "ans8": "\ue01b",
         "ans9": "\ue01b",
         "ans10": "\ue01b",
         "ans11": "\ue01b",
         "ans12": "\ue01b",
         "ans13": "\ue01b",
         "ans14": "\ue01b",
         "ans15": "\ue01b",
         "ans16": "\ue01f",
         "ans17": "\ue01f",
         "ans18": "\ue01f",
         "ans19": "\ue01f",
         "ans20": "\ue01f",
         "ans21": "\ue01f",
         "ans22": "\ue01f",
         "ans23": "\ue01f",
         "ans24": "\ue01f",
         "ans25": "\ue01f",
         "ans26": "\ue01f",
         "ans27": "\ue01f",
         "ans28": "\ue01f",
         "ans29": "\ue01f",
         "ans30": "\ue01f",
         "ans31": "\ue01f",
         "ans32": "\ue01f",
         "ans33": "\ue01f",
         "ans34": "\ue01f",
         "ans35": "\ue01f"
        
    ,
     "sec2":
         
            "ans1":1 "\ue01b",
            "ans2": "\ue01b",
            "ans3": "\ue01b",
            "ans4": "\ue01b",
            "ans5": "\ue01b",
            "ans6": "\ue01b",
            "ans7": "\ue01b",
            "ans8": "\ue01b",
            "ans9": "\ue01f",
            "ans10": "\ue01f",
            "ans11": "\ue01f",
            "ans12": "\ue01f",
            "ans13": "\ue01f",
            "ans14": "\ue01f",
            "ans15": "\ue01f",
            "ans16": "\ue01f"
         
    ,
     "sec3":
         
            "ans1": "\ue01b",
            "ans2": "\ue01b",
            "ans3": "\ue01b",
            "ans4": "\ue01b",
            "ans5": "\ue01b",
            "ans6": "\ue01b",
            "ans7": "\ue01b",
            "ans8": "\ue01b",
            "ans9": "\ue01b",
            "ans10": "\ue01b",
            "ans11": "\ue01f",
            "ans12": "\ue01f",
            "ans13": "\ue01f",
            "ans14": "\ue01f",
            "ans15": "\ue01f",
            "ans16": "\ue01f",
            "ans17": "\ue01f",
            "ans18": "\ue01f",
            "ans19": "\ue01b",
            "ans20": "\ue01b",
            "ans21": "\ue01b",
            "ans22": "\ue01b"
         
    ,
     "sec4":
         
            "ans1": "\ue01b",
            "ans2": "\ue01b",
            "ans3": "\ue01b",
            "ans4": "\ue01b",
            "ans5": "\ue01b",
            "ans6": "\ue01b",
            "ans7": "\ue01b",
            "ans8": "\ue01b",
            "ans9": "\ue01f",
            "ans10": "\ue01f",
            "ans11": "\ue01f",
            "ans12": "\ue01f",
            "ans13": "\ue01f",
            "ans14": "\ue01f",
            "ans15": "\ue01f",
            "ans16": "\ue01f",
            "ans17": "\ue01b",
            "ans18": "\ue01b",
            "ans19": "\ue01b",
            "ans20": "\ue01b"
         
      

"acuity2":
    "sec1":
               
        "ans1": "\ue01d",
         "ans2":"\ue01d",
         "ans3": "\ue01d",
         "ans4": "\ue01d",
         "ans5": "\ue01d",
         "ans6": "\ue01d",
         "ans7": "\ue01d",
         "ans8": "\ue01d",
         "ans9": "\ue01d",
         "ans10": "\ue01d",
         "ans11": "\ue01d",
         "ans12": "\ue01d",
         "ans13": "\ue01d",
         "ans14": "\ue01d",
         "ans15": "\ue01d",
         "ans16": "\ue01d",
         "ans17": "\ue01d",
         "ans18": "\ue01d",
         "ans19": "\ue01d",
         "ans20": "\ue01d",
         "ans21": "\ue01d",
         "ans22": "\ue01d",
         "ans23": "\ue01d",
         "ans24": "\ue01d",
         "ans25": "\ue01d",
         "ans26": "\ue01d",
         "ans27": "\ue01d",
         "ans28": "\ue01d",
         "ans29": "\ue01d",
         "ans30": "\ue01d",
         "ans31": "\ue01d",
         "ans32": "\ue01d",
         "ans33": "\ue01d",
         "ans34": "\ue01d",
         "ans35": "\ue01d"
        ,
     "sec2":
         
            "ans1":1 "\ue01d",
            "ans2": "\ue01d",
            "ans3": "\ue01d",
            "ans4": "\ue01d",
            "ans5": "\ue01d",
            "ans6": "\ue01d",
            "ans7": "\ue01d",
            "ans8": "\ue01d",
            "ans9": "\ue01d",
            "ans10": "\ue01d",
            "ans11": "\ue01d",
            "ans12": "\ue01d",
            "ans13": "\ue01d",
            "ans14": "\ue01d",
            "ans15": "\ue01d",
            "ans16": "\ue01d"
         
    ,
     "sec3":
         
            "ans1": "\ue01d",
            "ans2": "\ue01d",
            "ans3": "\ue01d",
            "ans4": "\ue01d",
            "ans5": "\ue01d",
            "ans6": "\ue01d",
            "ans7": "\ue01d",
            "ans8": "\ue01d",
            "ans9": "\ue01d",
            "ans10": "\ue01d",
            "ans11": "\ue01d",
            "ans12": "\ue01d",
            "ans13": "\ue01d",
            "ans14": "\ue01d",
            "ans15": "\ue01d",
            "ans16": "\ue01d",
            "ans17": "\ue01d",
            "ans18": "\ue01d",
            "ans19": "\ue01d",
            "ans20": "\ue01d",
            "ans21": "\ue01d",
            "ans22": "\ue01d"
         
    ,
     "sec4":
         
            "ans1": "\ue01d",
            "ans2": "\ue01d",
            "ans3": "\ue01d",
            "ans4": "\ue01d",
            "ans5": "\ue01d",
            "ans6": "\ue01d",
            "ans7": "\ue01d",
            "ans8": "\ue01d",
            "ans9": "\ue01d",
            "ans10": "\ue01d",
            "ans11": "\ue01d",
            "ans12": "\ue01d",
            "ans13": "\ue01d",
            "ans14": "\ue01d",
            "ans15": "\ue01d",
            "ans16": "\ue01d",
            "ans17": "\ue01d",
            "ans18": "\ue01d",
            "ans19": "\ue01d",
            "ans20": "\ue01d"
         
     
,
"acuity3":
    "sec1":
                  
           "ans1": "\ue01f",
            "ans2":"\ue01f",
            "ans3": "\ue01f",
            "ans4": "\ue01f",
            "ans5": "\ue01f",
            "ans6": "\ue01f",
            "ans7": "\ue01f",
            "ans8": "\ue01f",
            "ans9": "\ue01f",
            "ans10": "\ue01f",
            "ans11": "\ue01f",
            "ans12": "\ue01f",
            "ans13": "\ue01f",
            "ans14": "\ue01f",
            "ans15": "\ue01f",
            "ans16": "\ue01b",
            "ans17": "\ue01b",
            "ans18": "\ue01b",
            "ans19": "\ue01b",
            "ans20": "\ue01b",
            "ans21": "\ue01b",
            "ans22": "\ue01b",
            "ans23": "\ue01b",
            "ans24": "\ue01b",
            "ans25": "\ue01b",
            "ans26": "\ue01b",
            "ans27": "\ue01b",
            "ans28": "\ue01b",
            "ans29": "\ue01b",
            "ans30": "\ue01b",
            "ans31": "\ue01b",
            "ans32": "\ue01b",
            "ans33": "\ue01b",
            "ans34": "\ue01b",
            "ans35": "\ue01b"
           ,
    ,
        "sec2":
            
               "ans1":1 "\ue01f",
               "ans2": "\ue01f",
               "ans3": "\ue01f",
               "ans4": "\ue01f",
               "ans5": "\ue01f",
               "ans6": "\ue01f",
               "ans7": "\ue01f",
               "ans8": "\ue01f",
               "ans9": "\ue01b",
               "ans10": "\ue01b",
               "ans11": "\ue01b",
               "ans12": "\ue01b",
               "ans13": "\ue01b",
               "ans14": "\ue01b",
               "ans15": "\ue01b",
               "ans16": "\ue01b"
            ,
        ,
        "sec3":
            
               "ans1": "\ue01f",
               "ans2": "\ue01f",
               "ans3": "\ue01f",
               "ans4": "\ue01f",
               "ans5": "\ue01f",
               "ans6": "\ue01f",
               "ans7": "\ue01f",
               "ans8": "\ue01f",
               "ans9": "\ue01f",
               "ans10": "\ue01f",
               "ans11": "\ue01b",
               "ans12": "\ue01b",
               "ans13": "\ue01b",
               "ans14": "\ue01b",
               "ans15": "\ue01b",
               "ans16": "\ue01b",
               "ans17": "\ue01b",
               "ans18": "\ue01b",
               "ans19": "\ue01f",
               "ans20": "\ue01f",
               "ans21": "\ue01f",
               "ans22": "\ue01f"
            , 
        ,       
        "sec4":
            
               "ans1": "\ue01f",
               "ans2": "\ue01f",
               "ans3": "\ue01f",
               "ans4": "\ue01f",
               "ans5": "\ue01f",
               "ans6": "\ue01f",
               "ans7": "\ue01f",
               "ans8": "\ue01f",
               "ans9": "\ue01b",
               "ans10": "\ue01b",
               "ans11": "\ue01b",
               "ans12": "\ue01b",
               "ans13": "\ue01b",
               "ans14": "\ue01b",
               "ans15": "\ue01b",
               "ans16": "\ue01b",
               "ans17": "\ue01f",
               "ans18": "\ue01f",
               "ans19": "\ue01f",
               "ans20": "\ue01f"
            
          
   

【问题讨论】:

【参考方案1】:

从没有键的字典中删除大括号。编码值在字典中。它们应该是 ans 键的值。

此外,您在 ans1 处有错误(在另一个字典中重复),列后 1:

"sec2":
         
            "ans1":1 "\ue01d",
(...)

【讨论】:

谢谢!我注意到 ans1 的错误并在发布后更正了它。你能澄清一下从没有键的字典中删除花括号的问题吗?这是你的想法:“acuity1”:“sec1”:“ans1”:“\ue01b”,“ans2”:“\ue01b”, 所以,您按照我的建议进行了修复。请接受我的回答,谢谢。【参考方案2】:

原来我需要添加一些结尾并重新排列一下。 最终解决方案:

    "acuity1":[
    "sec1":[       
            "ans1": "\ue01b",
            "ans2":"\ue01b",
            "ans3": "\ue01b",
            "ans4": "\ue01b",
            "ans5": "\ue01b",
            "ans6": "\ue01b",
            "ans7": "\ue01b",
            "ans8": "\ue01b",
            "ans9": "\ue01b",
            "ans10": "\ue01b",
            "ans11": "\ue01b",
            "ans12": "\ue01b",
            "ans13": "\ue01b",
            "ans14": "\ue01b",
            "ans15": "\ue01b",
            "ans16": "\ue01f",
            "ans17": "\ue01f",
            "ans18": "\ue01f",
            "ans19": "\ue01f",
            "ans20": "\ue01f",
            "ans21": "\ue01f",
            "ans22": "\ue01f",
            "ans23": "\ue01f",
            "ans24": "\ue01f",
            "ans25": "\ue01f",
            "ans26": "\ue01f",
            "ans27": "\ue01f",
            "ans28": "\ue01f",
            "ans29": "\ue01f",
            "ans30": "\ue01f",
            "ans31": "\ue01f",
            "ans32": "\ue01f",
            "ans33": "\ue01f",
            "ans34": "\ue01f",
            "ans35": "\ue01f"
        ],
     "sec2":[
            "ans1": "\ue01b",
            "ans2": "\ue01b",
            "ans3": "\ue01b",
            "ans4": "\ue01b",
            "ans5": "\ue01b",
            "ans6": "\ue01b",
            "ans7": "\ue01b",
            "ans8": "\ue01b",
            "ans9": "\ue01f",
            "ans10": "\ue01f",
            "ans11": "\ue01f",
            "ans12": "\ue01f",
            "ans13": "\ue01f",
            "ans14": "\ue01f",
            "ans15": "\ue01f",
            "ans16": "\ue01f"
         ],
     "sec3":[
            "ans1": "\ue01b",
            "ans2": "\ue01b",
            "ans3": "\ue01b",
            "ans4": "\ue01b",
            "ans5": "\ue01b",
            "ans6": "\ue01b",
            "ans7": "\ue01b",
            "ans8": "\ue01b",
            "ans9": "\ue01b",
            "ans10": "\ue01b",
            "ans11": "\ue01f",
            "ans12": "\ue01f",
            "ans13": "\ue01f",
            "ans14": "\ue01f",
            "ans15": "\ue01f",
            "ans16": "\ue01f",
            "ans17": "\ue01f",
            "ans18": "\ue01f",
            "ans19": "\ue01b",
            "ans20": "\ue01b",
            "ans21": "\ue01b",
            "ans22": "\ue01b"
         ],
     "sec4":[
            "ans1": "\ue01b",
            "ans2": "\ue01b",
            "ans3": "\ue01b",
            "ans4": "\ue01b",
            "ans5": "\ue01b",
            "ans6": "\ue01b",
            "ans7": "\ue01b",
            "ans8": "\ue01b",
            "ans9": "\ue01f",
            "ans10": "\ue01f",
            "ans11": "\ue01f",
            "ans12": "\ue01f",
            "ans13": "\ue01f",
            "ans14": "\ue01f",
            "ans15": "\ue01f",
            "ans16": "\ue01f",
            "ans17": "\ue01b",
            "ans18": "\ue01b",
            "ans19": "\ue01b",
            "ans20": "\ue01b"
         ] , 
"acuity2":[
    "sec1":[       
            "ans1": "\ue01d",
            "ans2":"\ue01d",
            "ans3": "\ue01d",
            "ans4": "\ue01d",
            "ans5": "\ue01d",
            "ans6": "\ue01d",
            "ans7": "\ue01d",
            "ans8": "\ue01d",
            "ans9": "\ue01d",
            "ans10": "\ue01d",
            "ans11": "\ue01d",
            "ans12": "\ue01d",
            "ans13": "\ue01d",
            "ans14": "\ue01d",
            "ans15": "\ue01d",
            "ans16": "\ue01d",
            "ans17": "\ue01d",
            "ans18": "\ue01d",
            "ans19": "\ue01d",
            "ans20": "\ue01d",
            "ans21": "\ue01d",
            "ans22": "\ue01d",
            "ans23": "\ue01d",
            "ans24": "\ue01d",
            "ans25": "\ue01d",
            "ans26": "\ue01d",
            "ans27": "\ue01d",
            "ans28": "\ue01d",
            "ans29": "\ue01d",
            "ans30": "\ue01d",
            "ans31": "\ue01d",
            "ans32": "\ue01d",
            "ans33": "\ue01d",
            "ans34": "\ue01d",
            "ans35": "\ue01d"
        ],
     "sec2":[
            "ans1": "\ue01d",
            "ans2": "\ue01d",
            "ans3": "\ue01d",
            "ans4": "\ue01d",
            "ans5": "\ue01d",
            "ans6": "\ue01d",
            "ans7": "\ue01d",
            "ans8": "\ue01d",
            "ans9": "\ue01d",
            "ans10": "\ue01d",
            "ans11": "\ue01d",
            "ans12": "\ue01d",
            "ans13": "\ue01d",
            "ans14": "\ue01d",
            "ans15": "\ue01d",
            "ans16": "\ue01d"
         ],
     "sec3":[
            "ans1": "\ue01d",
            "ans2": "\ue01d",
            "ans3": "\ue01d",
            "ans4": "\ue01d",
            "ans5": "\ue01d",
            "ans6": "\ue01d",
            "ans7": "\ue01d",
            "ans8": "\ue01d",
            "ans9": "\ue01d",
            "ans10": "\ue01d",
            "ans11": "\ue01d",
            "ans12": "\ue01d",
            "ans13": "\ue01d",
            "ans14": "\ue01d",
            "ans15": "\ue01d",
            "ans16": "\ue01d",
            "ans17": "\ue01d",
            "ans18": "\ue01d",
            "ans19": "\ue01d",
            "ans20": "\ue01d",
            "ans21": "\ue01d",
            "ans22": "\ue01d"
         ],
     "sec4":[
            "ans1": "\ue01d",
            "ans2": "\ue01d",
            "ans3": "\ue01d",
            "ans4": "\ue01d",
            "ans5": "\ue01d",
            "ans6": "\ue01d",
            "ans7": "\ue01d",
            "ans8": "\ue01d",
            "ans9": "\ue01d",
            "ans10": "\ue01d",
            "ans11": "\ue01d",
            "ans12": "\ue01d",
            "ans13": "\ue01d",
            "ans14": "\ue01d",
            "ans15": "\ue01d",
            "ans16": "\ue01d",
            "ans17": "\ue01d",
            "ans18": "\ue01d",
            "ans19": "\ue01d",
            "ans20": "\ue01d"
         ],
"acuity3":[
    "sec1":[       
            "ans1": "\ue01f",
            "ans2":"\ue01f",
            "ans3": "\ue01f",
            "ans4": "\ue01f",
            "ans5": "\ue01f",
            "ans6": "\ue01f",
            "ans7": "\ue01f",
            "ans8": "\ue01f",
            "ans9": "\ue01f",
            "ans10": "\ue01f",
            "ans11": "\ue01f",
            "ans12": "\ue01f",
            "ans13": "\ue01f",
            "ans14": "\ue01f",
            "ans15": "\ue01f",
            "ans16": "\ue01b",
            "ans17": "\ue01b",
            "ans18": "\ue01b",
            "ans19": "\ue01b",
            "ans20": "\ue01b",
            "ans21": "\ue01b",
            "ans22": "\ue01b",
            "ans23": "\ue01b",
            "ans24": "\ue01b",
            "ans25": "\ue01b",
            "ans26": "\ue01b",
            "ans27": "\ue01b",
            "ans28": "\ue01b",
            "ans29": "\ue01b",
            "ans30": "\ue01b",
            "ans31": "\ue01b",
            "ans32": "\ue01b",
            "ans33": "\ue01b",
            "ans34": "\ue01b",
            "ans35": "\ue01b"
           ],
        "sec2":[
            "ans1": "\ue01f",
            "ans2": "\ue01f",
            "ans3": "\ue01f",
            "ans4": "\ue01f",
            "ans5": "\ue01f",
            "ans6": "\ue01f",
            "ans7": "\ue01f",
            "ans8": "\ue01f",
            "ans9": "\ue01b",
            "ans10": "\ue01b",
            "ans11": "\ue01b",
            "ans12": "\ue01b",
            "ans13": "\ue01b",
            "ans14": "\ue01b",
            "ans15": "\ue01b",
            "ans16": "\ue01b"
            ],
        "sec3":[
            "ans1": "\ue01f",
            "ans2": "\ue01f",
            "ans3": "\ue01f",
            "ans4": "\ue01f",
            "ans5": "\ue01f",
            "ans6": "\ue01f",
            "ans7": "\ue01f",
            "ans8": "\ue01f",
            "ans9": "\ue01f",
            "ans10": "\ue01f",
            "ans11": "\ue01b",
            "ans12": "\ue01b",
            "ans13": "\ue01b",
            "ans14": "\ue01b",
            "ans15": "\ue01b",
            "ans16": "\ue01b",
            "ans17": "\ue01b",
            "ans18": "\ue01b",
            "ans19": "\ue01f",
            "ans20": "\ue01f",
            "ans21": "\ue01f",
            "ans22": "\ue01f"
            ],       
        "sec4":[
            "ans1": "\ue01f",
            "ans2": "\ue01f",
            "ans3": "\ue01f",
            "ans4": "\ue01f",
            "ans5": "\ue01f",
            "ans6": "\ue01f",
            "ans7": "\ue01f",
            "ans8": "\ue01f",
            "ans9": "\ue01b",
            "ans10": "\ue01b",
            "ans11": "\ue01b",
            "ans12": "\ue01b",
            "ans13": "\ue01b",
            "ans14": "\ue01b",
            "ans15": "\ue01b",
            "ans16": "\ue01b",
            "ans17": "\ue01f",
            "ans18": "\ue01f",
            "ans19": "\ue01f",
            "ans20": "\ue01f"
            ]]
]]

【讨论】:

以上是关于机器人框架数据驱动场景的 JSON 格式的主要内容,如果未能解决你的问题,请参考以下文章

对于使用机器人框架的数据驱动测试,是不是可以有多个数据驱动程序(使用多个数据表)?

实战篇38 # 如何使用数据驱动框架 D3.js 绘制常用数据图表?

实战篇38 # 如何使用数据驱动框架 D3.js 绘制常用数据图表?

接口测试框架实战| JSON 请求与响应断言

VUE中使用工作流流程图树结构(JSON数据驱动动态树结构)

VUE中使用工作流流程图树结构(JSON数据驱动动态树结构)