How to process the json like properties list output by eggplant command?

Hello Team,

I have used to CompareScreen feature to valid few screen layout.
I am getting output as below.

log “diff”:CompareScreen (“Resourcedemand_Header”, rect:[“Demand/Header_TL”,“Demand/Header_BL”])


Log Resourcedemand_Header_0035.png Found 1 differences
5/26/23, 9:35:34 AM Log {diff:[{difference:“Changed”, differenceType:“Text”, rectangle:[20,67,217,109], source:“Combined”, text:“YAP Version v”, textNow:“000 Version”}]}

From that How to extreact the textNow value alone without using repeat loop.

Another output:

Log C:/BRAIN_2_0/Test.suite/Results/Fullscreen_compare/20230526_094642.846/project5555062021_0039.png Found 2 differences
5/26/23, 9:47:32 AM Log {diffs:[{difference:“Changed”, differenceType:“Text”, rectangle:[227,43,1616,64], source:“Combined”, text:“^s://10.139A73:444/reports/BSTCockpitChart/ee674c32-1f46-4011-bb79-0b67c505a762?reportld=90dcc303-62bf-4cfb-befb-410b899e5257&returnUrl=%2Freports%2FHistory%2Fee674c32-1f46-4011-bb79-0b67c505a762⏎”, textNow:“M^s://10.139A73:444/reports/BSTCockpitChart/ee674c32-1f46-4011-bb79-0b67c505a762?reportld=90dcc303-62bf-4cfb-befb-410b899e5257&returnUrl=%2Freports%2Fhistory%2Fee674c32-1f46-4011-bb79-0b67c505a762⏎”},{difference:“Changed”, differenceType:“Text”, rectangle:[1860,1056,1911,1073], source:“Combined”, text:“&18AM”}]}

from above property I need to extract textNow and text:

Is there any way quickly extarct the info without using repeat loop?

Your output is going to be a list of property lists with a separate item for each difference. A very efficient way of extracting a single key value from within each item involves a repeat loop.

CompareScreen "tutorialSUT_whole"
put the result into TSW_results
Repeat with each item myDifference of TSW_results
	If myDifference.TextNow is not empty then put "The current text is now" && myDifference.TextNow
End Repeat

Is there a specific reason why your use case prohibits repeat loops?

1 Like