An alternative submodule to behave-common-steps project. Author: Michal Odehnal modehnal@redhat.com
To use this submodule use command to add this to your project:
git submodule add -b f30 https://pagure.io/desktop-qa/behave-common-procedures.git 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
You need to change your environment.py file. This is an example how to setup your tests:
from common_procedures.sandbox import * import traceback import sys def before_all(context): try: 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)) traceback.print_exc(file=sys.stdout) sys.exit(1) def before_scenario(context, scenario): try: context.sandbox.before_scenario(context, scenario) except Exception as e: print("Environment error: before_scenario: {0}".format(e)) traceback.print_exc(file=sys.stdout) sys.exit(1) def after_step(context, step): try: context.sandbox.after_step(context, step) except Exception as e: print("Environment error: after_step: {0}".format(e)) traceback.print_exc(file=sys.stdout) sys.exit(1) def after_scenario(context, scenario): try: context.sandbox.after_scenario(context, scenario) except Exception as e: print("Environment error: after_scenario: {0}".format(e)) traceback.print_exc(file=sys.stdout) sys.exit(1)
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 steps.py 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 *
Main change is the query for node in a11y tree. You are used to:
context.app.instance.<whatever>
You will now be using your defined application from environment.
context.terminal.instance.<whatever> context.firefox.instance.<whatever> context.nautilus.instance.<whatever>
You get the idea.
Examples:
* 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"