我已经嵌套了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}
我是这样做的:
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}