desktop-qa / behave-common-procedures

Created 18 days ago
Maintained by pschindl
Behave procedures - steps which can be used in multiple projects using behave to test desktop
Members 1
Petr Schindler committed 14 days ago

Project behave-common-procedures

An alternative submodule to behave-common-steps project. Author: Michal Odehnal

Getting Started

To use this submodule use command to add this to your project:

git submodule add -b f30 common_procedures --force


To use some parts of the submodule you may need some libraries:

To use opencv image matching you will need (this will be needed in CI and you need to include the package in your mapper.yaml):

sudo pip3 install opencv-python

And to use included error message format in color you will need (this will not be needed in CI):

sudo pip3 install termcolor

Setup in environment

You need to change your file. This is an example how to setup your tests:

from common_procedures.sandbox import *
import traceback
import sys

def before_all(context):
        context.sandbox = TestSandbox("gnome-terminal")

        context.terminal = context.sandbox.get_app("gnome-terminal", a11yAppName="gnome-terminal-server")
    except Exception as e:
        print("Environment error: before_all: {0}".format(e))

def before_scenario(context, scenario):
        context.sandbox.before_scenario(context, scenario)
    except Exception as e:
        print("Environment error: before_scenario: {0}".format(e))

def after_step(context, step):
        context.sandbox.after_step(context, step)
    except Exception as e:
        print("Environment error: after_step: {0}".format(e))

def after_scenario(context, scenario):
        context.sandbox.after_scenario(context, scenario)
    except Exception as e:
        print("Environment error: after_scenario: {0}".format(e))

Setup in main code

When you run your tests now and there is no exception caught in environment. That means the environment was setup correctly. To use this setup in your file you need another import:

from common_procedures.common_steps import *

And if you would like image matching you will need:

from common_procedures.image_matching import *

Usage in

Main change is the query for node in a11y tree. You are used to:<whatever>

You will now be using your defined application from environment.


You get the idea.

Usage in .feature files.


  * Start application "terminal" via "menu"
  * Close application "terminal" via "shortcut"

  * Left click "System" "menu" in "gnome-shell"
  * Left click "Settings" "push button" that is "showing" in "gnome-shell"
  * Item "Settings" "menu" is "showing" in "gnome-shell"

Files included explained

  • - collection of useful functions.
  • - application class that contains methods to deal with applications.
  • - behave wrapper for dogtail.
  • - get_node class that does all asserting and searching for desired node wanted via
  • - opencv image comparison.
  • - main testing class which takes care of all system settings for successful test run.
  • - script for start recording test via dbus.
  • - experimental function for time limiting certain tests.