-
Notifications
You must be signed in to change notification settings - Fork 665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Tests-Only]Enabled screenshot of desktop on test failure #9518
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,24 @@ def hook(context): | |
|
||
@OnScenarioEnd | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that will create an screenshot AFTER the issue There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the app is not closed automatically after the crash then the screenshot is captured that shows the state of crash. For instance in #9518 (comment) Otherwise, the only option that I can think of right now is to capture the video of test run (anyway) and then delete it if there is no test error. I can not say that can be done easily. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But this could be a good enhancement. I will open an issue. May be we can try it later. |
||
def hook(context): | ||
# capture screenshot if there is error in the scenario execution, and if the test is being run in CI | ||
if test.resultCount("errors") > 0 and os.getenv('CI'): | ||
import gi | ||
kiranparajuli589 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
gi.require_version('Gtk', '3.0') | ||
from gi.repository import Gdk | ||
|
||
window = Gdk.get_default_root_window() | ||
pb = Gdk.pixbuf_get_from_window(window, *window.get_geometry()) | ||
|
||
filename = context._data["title"].replace(" ", "_") + ".png" | ||
directory = os.environ["GUI_TEST_REPORT_DIR"] + "/screenshots" | ||
|
||
if not os.path.exists(directory): | ||
os.makedirs(directory) | ||
|
||
pb.savev(os.path.join(directory, filename), "png", [], []) | ||
|
||
# Detach (i.e. potentially terminate) all AUTs at the end of a scenario | ||
for ctx in applicationContextList(): | ||
ctx.detach() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also $1 $2 $3 should be given nice names
both could happen in a different PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$GUI_TEST_REPORT_DIR is
/drone/src/test/guiReportUpload
. We either need to create new env variable to store the directory nameguiReportUpload
or we should leave it as it is, AFAIK.And yes, we can give some nice name to all the variables, that can be done in some other PR.