-
Notifications
You must be signed in to change notification settings - Fork 69
GUI testing
Antti Kervinen edited this page Apr 1, 2014
·
22 revisions
fMBT provides utilities for GUI testing:
- Python libraries that implement similar GUI test interface for multiple platforms
- fmbtandroid for Android phones, tablets and emulator
- fmbttizen for Tizen mobile (X server) and Tizen IVI (Wayland + Weston)
- fmbtvnc for anything that runs a VNC server
- fmbtwindows for Windows desktops, laptops and tablets
- fmbtx11 for an X server
- fmbt-scripter - a tool for
- capturing reference bitmaps from screenshots from Android, Tizen, VNC, Windows and X
- editing and debugging for Python GUI test scripts.
GUI test interfaces for multiple platforms have a lot in common, but also some platform-specific extensions.
While this document gives only an overview, you will get full parameter and return value documentation for each GUI test interfaces with Python:
python -c 'import fmbtandroid; help(fmbtandroid.Device)'
python -c 'import fmbttizen; help(fmbttizen.Device)'
python -c 'import fmbtvnc; help(fmbtvnc.Screen)'
python -c 'import fmbtwindows; help(fmbtwindows.Device)'
python -c 'import fmbtx11; help(fmbtx11.Screen)'
If you want help from a single method, use python -c 'import
fmbtandroid; help(fmbtandroid.Device.refreshScreenshot)'
, for
instance.
-
refreshScreenshot
fetches the latest screenshot from the device under test. <act>Bitmap and <act>OcrText methods (liketapBitmap
,swipeOcrText
) use most recently fetched screenshot. -
refreshView
fetches UI elements currently on the screen. <act>Text methods (liketapText
) use most recently fetched UI element information.
fmbtandroid | fmbttizen | fmbtvnc | fmbtwindows | fmbtx11 | |
refreshScreenshot | Y | Y | Y | Y | Y |
refreshView | Y |
-
verifyBitmap
andverifyOcrText
return True if a bitmap or a text is recognized from latest screenshot. -
verifyText
returns True if a UI element with a text is found from latest UI element information.
fmbtandroid | fmbttizen | fmbtvnc | fmbtwindows | fmbtx11 | |
verifyBitmap verifyOcrText | Y | Y | Y | Y | Y |
verifyText | Y |
- tap<what> sends touch down and touch up (or mouse button down, mouse button up) on given location. The location can be given in coordinates or unity coordinates, or it can be based on a bitmap, text recognized by OCR, or a text from UI elements.
- platforms that support both touch and mouse events will get a touch event by default. When called with optional argument button=X, a mouse event with button X is sent. If button=0, then only mouse move is sent, resulting in hovering over given location.
fmbtandroid | fmbttizen | fmbtvnc | fmbtwindows | fmbtx11 | |
drag | touch | touch mouse | mouse | touch mouse | mouse |
swipe, swipeBitmap, swipeOcrText | touch | touch mouse | mouse | touch mouse | mouse |
swipeText | touch | ||||
tap, tapBitmap, tapOcrText | touch | touch mouse | mouse | touch mouse | mouse |
tapText | touch |
-
pressKey
sends a key press and release. -
type
types given text.
fmbtandroid | fmbttizen | fmbtvnc | fmbtwindows | fmbtx11 | |
pressKey | Y | Y | Y | Y | Y |
type | Y | Y | Y | Y | Y |
-
shellSOE
executes given shell command and returns triplet: (Status, Output, Error), that is 1) child process exit status 2) what was printed to standard output 3) what was printed to standard error
fmbtandroid | fmbttizen | fmbtvnc | fmbtwindows | fmbtx11 | |
shellSOE | Y | Y | Y |
-
enableVisualLog
starts tracing all GUI test interface method calls, return values, exceptions, captured screenshots and reference bitmaps to given HTML file. -
fmbtlogger.text
andfmbtlogger.csv
log method calls, return values and exceptions of any Python object, including GUI test interfaces. The log format is plain text or CSV. Seepython -c 'import fmbtlogger; help(fmbtlogger.text)'
for more information.
fmbtandroid | fmbttizen | fmbtvnc | fmbtwindows | fmbtx11 | |
enableVisualLog | Y | Y | Y | Y | Y |
Prerequisites:
-
adb
from Android SDK, Platform tools - Enable USB debugging from device settings.
Example:
import fmbtandroid d = fmbtandroid.Device() d.swipe((0.5, 0.85), "east") # open lock screen
Prerequisites:
-
sdb
from Tizen SDK for testing a Tizen mobile device -
ssh
for testing Tizen IVI
Tizen mobile example:
import fmbttizen d = fmbttizen.Device() d.pressPower()
Tizen IVI example:
import fmbttizen d = fmbttizen.Device(loginCommand="ssh root@ivi") d.refreshScreenshot().save("current-screen.png")
Prerequisites:
- Install vncdotool: https://github.com/sibson/vncdotool
Example:
import fmbtvnc d = fmbtvnc.Screen("IP-ADDRESS-OF-VNC-SERVER") d.tap((0.5, 0.5), button=0) # hover mouse on the middle of the screen
Prerequisites for Windows device:
- Install Python 2.X.
- Copy fMBT's pythonshare directory to Windows.
- In the pythonshare directory, run
c:\python27\python.exe setup.py install
- Launch pythonshare-server to which fmbtwindows can connect to:
cd \python27\scripts python pythonshare-server --interface=all --password=xxxxxxxx
Example:
import fmbtwindows d = fmbtwindows.Device("IP-ADDRESS-OF-THE-DEVICE", password="xxxxxxxx") d.type("Hello Windows")
Example:
import fmbtx11 d = fmbtx11.Screen(":2") d.enableVisualLog("calls.html") d.refreshScreenshot()