我有嵌套的dict变量,并希望从中提取值,以比较它是否等于实际值。对于键,它工作得很好,但是对于嵌套的dict,我没有找到一种如何提取值的方法(例如operatorid)。你对怎么做有什么建议吗?变量
${HIRING_DATA_TYPES}= {'Job Profile': {"AND":"", "operatorId": 'in the selection list', "targetInstances": 'Finance'},
... 'Recruiter': {"AND":"", "operatorId": 'not in the selection list', "targetInstances": '3314 Tax'},'Job Requisition': {"AND":"", "operatorId": 'is not empty'},
... 'Description': {"AND":"", "operatorId": 'equal to', "dataType":"Text", "targetType": 'targetText', "targetValue": "SDET_text"},
... 'Description 2': {"AND":"", "operatorId": 'greater than', "dataType":"Text", "targetType": "targetText", "targetValue": "SDET_text"},
... 'Description 3': {"AND":"", "operatorId": 'greater than or equal to', "dataType":"Text", "targetType": "targetText", "targetValue": "SDET_text"}}提取键
Check Added Source Fields
[Arguments] ${RESPONSE} ${FILTERS_TO_ADD}
${ACTUAL_SOURCE_FIELDS}= Get Json Path ${RESPONSE} $.pipelines..filter..children..field..descriptor
Sort list ${ACTUAL_SOURCE_FIELDS}
${FILTERS_TO_ADD}= Evaluate ${HIRING_DATA_TYPES}
${EXPECTED_SOURCE_FIELDS}= Get Dictionary Keys ${FILTERS_TO_ADD}
Lists Should Be Equal ${ACTUAL_SOURCE_FIELDS} ${EXPECTED_SOURCE_FIELDS}发布于 2021-08-03 12:28:13
它对我起作用的方式如下:
Check Added Comp Operators and Values
[Arguments] ${RESPONSE} ${FILTERS_TO_ADD}
@{EXPECTED_COMP_OPERATOR}= Create List
FOR ${key} IN @{HIRING_DATA_TYPES.keys()}
${COMP_OPER_VALUES}= Get From Dictionary ${HIRING_DATA_TYPES}[${key}] operatorId
Append To List ${EXPECTED_COMP_OPERATOR} ${COMP_OPER_VALUES}
END
Lists Should Be Equal ${ACTUAL_COMP_OPER} ${EXPECTED_COMP_OPERATOR}https://stackoverflow.com/questions/68627265
复制相似问题