That’s a thoughtful question — and you're right to be cautious about clicking within the canvas without confirming the element underneath.
Since Canvas content is not part of the DOM, TestComplete can’t directly inspect it. However, here are two approaches you can consider to validate that you're targeting the correct element:
If your application gives a visual indication (like a highlight or color change) when hovering over a Canvas element, you can simulate a hover on the coordinates and visually compare that region to a known reference.
This uses TestComplete’s built-in image comparison features, such as:
- Picture – to capture a snapshot of a region on the canvas.
- Region.Check – to compare it against a stored baseline image.
📘 Relevant Documentation:
This option is useful when you cannot programmatically confirm what's at the coordinates but you can detect visual changes.
If your app includes a JavaScript method such as getElementAt(x, y), you can call that directly from your TestComplete script using the Evaluate method.
This allows you to validate what element is at the given coordinates before clicking, using your application’s own internal logic.
📘 Relevant Documentation:
Example (conceptual):
isCorrect = page.Evaluate("return getElementAt(150, 100) === 'SaveButton';")
if isCorrect:
canvas.Click(150, 100)
This approach depends on your application exposing such APIs.
🤖 AI-assisted response
👍 Found it helpful? Click Like
✅ Issue resolved? Click Mark as Solution