-
Notifications
You must be signed in to change notification settings - Fork 69
fMBT GUI Test Interface FAQ
Questions:
- Why locating a bitmap fails?
- How can I avoid repeating OIR parameters on every *Bitmap method call?
- How can I get coordinates of a bitmap?
Compared screenshot and reference bitmap do not match. For instance, transparency, scaling, antialiasing and slight palette changes are difficult or impossible to see with bare eye, but may cause recognition of the bitmap fail.
*Bitmap (tapBitmap, ...) methods require 100 % exact match by default. This can be relaxed by adjusting OIR (optical image recognition) parameters. For instance,
>>> d.tapBitmap("ref-image.png", colorMatch=0.8)
allows 20 % difference on each color channel value on pixel-to-pixel comparisons. Even a bigger threshold may be needed to cope with partial transparency.
fMBT's default OIR engine has a method that searches for OIR parameters that enable finding a reference bitmap on a screenshot. Example:
>>> d.oirEngine().adjustParameters(d.screenshot(), "ref-bitmap.png")
For more information, see
>>> help(d.oirEngine())
>>> help(d.oirEngine().adjustParameters)
How can I avoid repeating OIR parameters on every *Bitmap method call?
OIR parameters can be provided in .fmbtoirrc
files. Parameters given in the file apply to all reference bitmaps in the same directory. An example of a pretty liberal .fmbtoirrc
:
colorMatch = 0.8
bitmapPixelSize = 2
screenshotPixelSize = 2
Parameters given in *Bitmap method calls in test scripts will override parameters read from the .fmbtoirrc
file.
Coordinates of a bitmap are available through found Item
instances. Example:
>>> allItems = d.screenshot().findItemsByBitmap("ref-image.png")
>>> firstItem = allItems[0]
>>> print "(x1, y1, x2, y2) ==", firstItem.bbox()
>>> print "center (x, y) ==", firstItem.coords()