Test canvas apps and games
A canvas draws its content as pixels. A slot game, a table game, a chart or a map on a <canvas> has no buttons or text in the page for a test to select or read. The Wopee.io agent tests it the way a player does: it presses keys and clicks positions on the screen, checks that the app reacted, and reads the result from the screen.
What this page covers
- When you need this guide
- How the agent acts on a canvas
- How it checks that the game reacted
- Click by coordinates: a click map
- Write the tests
- Games and wallets inside iframes
- Timing
- Limits
- Example suite
When you need this guide
Use it when the part of your app you test is drawn on a canvas or with WebGL:
- slot, table, draw and other HTML5 games;
- charts and dashboards drawn on a canvas;
- maps, editors and whiteboards.
The pages around a game, such as sign-in, registration, deposit and withdrawal, are ordinary web pages. Test them as usual; this guide covers what changes on the canvas.
How the agent acts on a canvas
Keys first. When the game has a keyboard control, such as Space to spin or the arrow keys to change the stake, the agent uses the Press tool. A key can be held for a set duration, for controls that react only to press-and-hold, such as autoplay.
Clicks by screen position when there is no key. The Visual click tool clicks a position on the screen. The agent gives the position as a share of the viewport (for example 79% across and 74% down), so it survives a different screen size.
Prefer keys where the game offers them. A key press goes to the game itself, while a click lands on whatever is drawn at that point, and controls on a canvas are often small and close together.
Both tools are described in Tools & Assertions.
How it checks that the game reacted
A key press or a click can reach the browser while the game ignores it, for example when a pop-up covers the game or the game is still loading. The agent therefore checks the effect, not only the delivery:
- Key presses. When the frame the key goes to holds a canvas, the agent takes a picture of the game before and after the press. Pixels that move on their own before the press, such as idle animation, are left out of the comparison. If nothing else changed, the press is reported as having no effect, the agent is told not to count it, and a sequence of presses stops there.
- Clicks. A screen-position click on a canvas is compared in the same way. When nothing changed, the agent can correct the point once, by looking again at the area around it, and click again. A second miss stands.
- The verdict. Integrity gates check every run for an input that never reached the page and for an assertion that never ran. In the default Report only mode, such a pass is flagged in amber; in Enforce mode it becomes Incomplete. See Verdict Integrity.
A press reported as having no effect is a finding in itself: either the game did not react, or the test pressed the wrong key at the wrong time. The run report shows which press it was.
Click by coordinates: a click map
When a control has no key, the agent clicks a point on the screen. You can let the agent find the point on a screenshot, or give it the point yourself. On a game, give it yourself: the controls are small and close together, and a point from a table is the same on every run.
How a point is written
A Visual click takes a point in one of two forms:
| Form | Example | Meaning |
|---|---|---|
| Percentage of the browser viewport | {"x":"50%","y":"88%"} |
0% is the left or top edge, 100% the right or bottom edge |
| CSS pixels | {"x":640,"y":634} |
Pixels from the top-left corner of the viewport |
- Both coordinates use the same form. A percentage outside 0-100 or a pixel outside the viewport is rejected, and the step fails with a message instead of clicking somewhere else.
- The agent passes pixels written in a test through unchanged. When it picks a point from a screenshot itself, it uses percentages.
- Agent runs use a browser viewport of 1280x720, so 1% is 12.8 px across and 7.2 px down.
Percentages are of the browser viewport, not of the game
A point such as 50% across is measured on the whole browser window, including the page around the game. If the game keeps its size and position when the window changes, a point measured at 1280x720 lands somewhere else at another size. Keep one click map per viewport size, and if a test changes the size with Resize viewport, use the map for that size.
Build the map
- Keys first. Map only the controls the game offers no key for.
- Take a screenshot at the run size. Use a step screenshot from a run in Commander, which is 1280x720, or your own browser set to the same viewport.
- Measure the centre of each control. Divide its x by the width and its y by the height, and multiply by 100. The centre leaves the most room for a small error.
- Write down what proves each click worked: a panel opens, a value changes, a notice closes.
- Put the map in the project context, so every test uses the same points.
- Check the map with one test that clicks each control and asserts its effect. A wrong point shows up as a click with no effect in the run report.
- Measure again when the game layout changes, for example after a new game version.
Example map
A generic slot game at 1280x720:
| Control | Key | Point (% of viewport) | Point (px at 1280x720) | What proves the click worked |
|---|---|---|---|---|
| Spin | Space | 50%, 88% | 640, 634 | The reels start moving |
| Stake up | Arrow up | 62%, 88% | 794, 634 | The stake shows one step higher |
| Stake down | Arrow down | 38%, 88% | 486, 634 | The stake shows one step lower |
| Autoplay | none | 72%, 88% | 922, 634 | The autoplay panel opens |
| Menu | none | 4%, 6% | 51, 43 | The game menu opens |
| Continue on the play-for-fun notice | none | 50%, 62% | 640, 446 | The notice closes and the reels show |
In the project context, write it as text the agent can follow:
GAME CONTROLS (viewport 1280x720, points as % of the browser viewport)
- Spin: press Space. If Space has no effect, visual click x 50%, y 88%.
- Stake up: press Arrow up. Stake down: press Arrow down.
- Autoplay: visual click x 72%, y 88%; the autoplay panel opens.
- Menu: visual click x 4%, y 6%; the game menu opens.
- Play-for-fun notice: visual click Continue at x 50%, y 62%; the notice closes.
In a scripted test, a Visual click step carries the point as its value, for example {"x":"72%","y":"88%"}.
How the agent uses the points
- When the agent runs several actions as one fast sequence, it cannot stop to look for a control, so every visual click in the sequence needs a point. The map provides it.
- Every click on a canvas is checked against the picture before and after. Outside a sequence, a click that changed nothing is corrected once, as described above. Inside a sequence there is no correction, so a wrong point has to be fixed in the map.
Write the tests
Write canvas tests like any other intent-driven test: the goal, what must be true afterwards, and the data. A few rules matter more on a canvas.
- Name the control, its key and its point. If the game has keyboard controls, write them into the test or the project context: "Space starts a spin. Arrow up raises the stake." For controls without a key, add their point from the click map. The agent then presses keys and clicks known points instead of guessing positions.
- One action, then its proof. After each action that matters, say what must change on screen: the balance goes down by the stake, the spin counter goes up, the win line appears.
- Assert the change, not the number. A balance differs on every run. Write "The balance is lower than before the spin by the stake" or check its format, never a literal amount. See the tip in Tools & Assertions.
- Read values with a Visual assert. A canvas has no text to select, so the Visual assert tool reads the balance, the stake or a message from the screen. Phrase it as a question about what a player sees: "Does the stake show 0.20?"
- Count repeated actions. For "spin ten times", say how the count is proven, for example "the spin counter shows 10" or "the balance is lower by ten stakes".
- Check the record, not the banner. A deposit or withdrawal banner often disappears within seconds. Check the entry in the account or transaction history instead.
Games and wallets inside iframes
Games usually run inside an iframe served from the game provider's domain, sometimes several frames deep. Wallets and payment forms are often iframes too. You do not need to tell the agent which frame to use:
- elements inside child frames, including cross-origin frames, are found automatically (see Self-Healing);
- a key press goes into the frame the game runs in, not to the page around it.
Timing
- Animations. A spin or a card deal takes time. Use a Poll assert for a value that appears only after the animation ends; it repeats the check until it passes or the deadline is reached.
- Pop-ups over the game. Play-for-fun notices, session reminders and promotions can cover the game at any time. Say in the test or the project context how to close them, for example "Close any pop-up with its Continue button before the next spin."
- Autoplay. If autoplay starts with a held key, say which key and for how long, and say how to prove the number of spins.
- Long sequences. A run has a time limit. Split many spins in a row into several shorter tests.
Limits
- Wopee.io tests the game UI, the player flows and the responsible-gaming controls. It does not test RNG, RTP or game fairness; that certification stays with accredited labs.
- Use play-for-fun mode or test accounts. Never test with real money.
- Card payments that ask for a one-time code (3-D Secure) need test cards or a payment flow without the code.
- The agent sees the screen at the moment it takes a picture. A result that shows for a fraction of a second can be missed; check where it is recorded instead.
Example suite
A suite for a slot game behind a player account. Each block is the Description of one intent-driven test; the steps stay empty.
GOAL: A signed-in player opens the slot game in play-for-fun mode.
PASSES WHEN:
- The game loads and shows the reels, the balance and the stake.
- The balance and the stake are shown as amounts with two decimals.
MUST NOT:
- An error message or an empty game frame is shown.
DATA: Sign in with ${TESTING_USERNAME} and ${TESTING_PASSWORD}.
GOAL: A player spins once with the default stake.
PASSES WHEN:
- After the spin, the balance is lower than before by the stake, or higher if the spin won.
- The reels show a new result.
MUST NOT:
- A press of Space is reported as having no effect.
DATA: Space starts a spin. Close any play-for-fun notice with its Continue button first.
GOAL: A player raises the stake by one step and spins.
PASSES WHEN:
- The stake shown after pressing Arrow up is one step higher than before.
- After the spin, the balance changed by the new stake, or by a win.
MUST NOT:
- The stake stays the same after the key press.
DATA: Arrow up raises the stake. Space starts a spin.
GOAL: A player runs ten spins with autoplay.
PASSES WHEN:
- The spin counter shows 10 when autoplay stops.
- The balance is lower than before by at most ten stakes, plus any wins.
MUST NOT:
- Autoplay stops before ten spins without a message.
DATA: Open autoplay with its button and choose 10 spins.
GOAL: A signed-in player withdraws a small amount.
PASSES WHEN:
- The transaction history shows a new withdrawal request for the amount.
MUST NOT:
- The test relies on the confirmation banner alone.
DATA: Withdraw ${WITHDRAW_AMOUNT} to the saved test account.