mqscript_cmpcolor
Compare screen color at specified coordinates with expected color value using similarity tolerance for automated mobile testing and UI validation.
Instructions
Compare color at specified point with expected color
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| expectedColor | Yes | Expected color in BBGGRR format | |
| resultVariable | No | Variable name to store comparison result | result |
| similarity | No | Color similarity tolerance (0-1) | |
| x | Yes | X coordinate to check | |
| y | Yes | Y coordinate to check |
Implementation Reference
- src/tools/basic-commands.ts:540-551 (handler)The handler function for the 'mqscript_cmpcolor' tool. It generates MQScript code to compare the color at specified coordinates with an expected color value using similarity tolerance, and outputs a trace message based on the result.handler: async (args: { x: number; y: number; expectedColor: string; similarity?: number; resultVariable?: string }) => { const { x, y, expectedColor, similarity = 0.9, resultVariable = 'result' } = args; const script = `Dim ${resultVariable}\n${resultVariable} = CmpColor(${x}, ${y}, "${expectedColor}", ${similarity})\nIf ${resultVariable} Then\n TracePrint "Color matches at (${x}, ${y})"\nElse\n TracePrint "Color does not match at (${x}, ${y})"\nEnd If`; return { content: [ { type: 'text', text: `Generated MQScript compare color command:\n\`\`\`\n${script}\n\`\`\`\n\nThis compares color at (${x}, ${y}) with expected color "${expectedColor}" using ${similarity} similarity.` } ] }; }
- src/tools/basic-commands.ts:512-538 (schema)The input schema defining parameters for the 'mqscript_cmpcolor' tool: x, y coordinates, expectedColor, optional similarity and resultVariable.inputSchema: { type: 'object' as const, properties: { x: { type: 'number', description: 'X coordinate to check' }, y: { type: 'number', description: 'Y coordinate to check' }, expectedColor: { type: 'string', description: 'Expected color in BBGGRR format' }, similarity: { type: 'number', description: 'Color similarity tolerance (0-1)', default: 0.9 }, resultVariable: { type: 'string', description: 'Variable name to store comparison result', default: 'result' } }, required: ['x', 'y', 'expectedColor']
- src/tools/basic-commands.ts:509-552 (registration)The full tool definition object for 'mqscript_cmpcolor' within ColorCommands, including name, description, inputSchema, and handler. This is where the tool is structured for registration.cmpColor: { name: 'mqscript_cmpcolor', description: 'Compare color at specified point with expected color', inputSchema: { type: 'object' as const, properties: { x: { type: 'number', description: 'X coordinate to check' }, y: { type: 'number', description: 'Y coordinate to check' }, expectedColor: { type: 'string', description: 'Expected color in BBGGRR format' }, similarity: { type: 'number', description: 'Color similarity tolerance (0-1)', default: 0.9 }, resultVariable: { type: 'string', description: 'Variable name to store comparison result', default: 'result' } }, required: ['x', 'y', 'expectedColor'] }, handler: async (args: { x: number; y: number; expectedColor: string; similarity?: number; resultVariable?: string }) => { const { x, y, expectedColor, similarity = 0.9, resultVariable = 'result' } = args; const script = `Dim ${resultVariable}\n${resultVariable} = CmpColor(${x}, ${y}, "${expectedColor}", ${similarity})\nIf ${resultVariable} Then\n TracePrint "Color matches at (${x}, ${y})"\nElse\n TracePrint "Color does not match at (${x}, ${y})"\nEnd If`; return { content: [ { type: 'text', text: `Generated MQScript compare color command:\n\`\`\`\n${script}\n\`\`\`\n\nThis compares color at (${x}, ${y}) with expected color "${expectedColor}" using ${similarity} similarity.` } ] }; } }