Confidence Levels

Adjust the confidence parameter to control matching accuracy:

Strict (0.8 - 1.0)

python
find(driver, 'button.png', confidence=0.9)

Use when: Element must match exactly, no false positives allowed

Balanced (0.7) - RECOMMENDED

python
find(driver, 'button.png', confidence=0.7)

Use when: Good balance between accuracy and flexibility (default)

Relaxed (0.5 - 0.6)

python
find(driver, 'button.png', confidence=0.5)

Use when: Element varies slightly, more flexible matching needed

Recommendation: Start with 0.7 and adjust based on results. If elements aren't found, lower it. If getting false positives, raise it.

Measure Instead of Guessing

match_score() reports how close a template actually came, so you can pick a number rather than working down from 0.7 by trial and error:

python
from pyxelator import match_score

print(match_score(driver.get_screenshot_as_png(), 'button.png'))
ScoreWhat it means
0.9 - 1.0Solid match. If find() still fails, your threshold is too high
0.7 - 0.9Match. The normal range for a real element
0.5 - 0.7Weak. Element is probably there but looks different, or the template caught surrounding layout
below 0.4Not on screen. Lowering confidence will not help
NoneUnusable template: solid colour, bigger than the screen, or not a readable image
Do not reach for 0.5 by reflex. A low threshold does not find a missing element, it invents one, and the click then lands wherever the false match happened to sit. If the score is below 0.4, the problem is the page or the timing, not the number.