Skip to content
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

Add API to capture screenshots of desktop/screen #2063

Closed
freakboy3742 opened this issue Aug 4, 2023 · 2 comments
Closed

Add API to capture screenshots of desktop/screen #2063

freakboy3742 opened this issue Aug 4, 2023 · 2 comments
Labels
enhancement New features, or improvements to existing features.

Comments

@freakboy3742
Copy link
Member

freakboy3742 commented Aug 4, 2023

What is the problem or limitation you are having?

As an app developer, it is sometimes necessary to capture the current entire desktop state of a GUI as an image.

The most notable use case is in CI testing, where the screen isn't visible, and test failures are most obvious in their visual presentation; however, there may be some other uses (e.g., an actual "screenshot" app)

Describe the solution you'd like

  1. A cross-platform API to capture an image of the full screen.

  2. As an example of the API in action, modify the testbed test harness so that when a test fails, a screenshot of the screen is captured and written to the cache directory.

Describe alternatives you've considered

Do nothing. Screenshots aren't essential; they're a nice-to-have feature.

Additional context

  • See Add API to capture screenshots of windows. #2062 for a similar feature at the level of a Window.
  • The API proposed in Added APIs for detecting multiple displays and setting windows on them. #1930 provides an entry point for accessing screens; based on that API, App.screens[n].as_image() would seem a logical API.
  • The Canvas GUI tests already have tests that write the as_image() representation to disk if the canvas hasn't rendered correctly.
  • It should be possible to catch a failed test in the teardown of the window_probe() and/or app_probe fixtures in testbed; if an AssertionError is raised during the yield, that will be a test failure; if this occurs, take a screenshot of the window/screen, write to the app cache folder, and re-raise the assertion (so that it is picked up by Pytest).
@proneon267
Copy link
Contributor

Since, #1930 is merged, I think this can be closed.

@freakboy3742
Copy link
Member Author

Agreed - thanks for the housekeeping!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features, or improvements to existing features.
Projects
None yet
Development

No branches or pull requests

2 participants