-
Notifications
You must be signed in to change notification settings - Fork 12
feat: enhance screenshot handling with file paths #127
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
Conversation
mmmay0722
commented
Jan 8, 2026
- Add screenshots_paths support alongside base64 screenshots in test results
- Implement screenshot prefix context variable to prevent filename collisions in parallel execution
- Improve screenshot session management with better directory organization
- Update case executor to support case_id and handle screenshot paths
- Enhance function tester and UX tester with screenshot path tracking
- Bump version to 0.2.3
…ion support - Add screenshots_paths support alongside base64 screenshots in test results - Implement screenshot prefix context variable to prevent filename collisions in parallel execution - Improve screenshot session management with better directory organization - Update case executor to support case_id and handle screenshot paths - Enhance function tester and UX tester with screenshot path tracking - Bump version to 0.2.3
Summary of ChangesHello @mmmay0722, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly upgrades the test reporting capabilities by overhauling how screenshots are captured, stored, and integrated into test results. It introduces the ability to save screenshots as local files, alongside base64 data, and implements a robust system for organizing these files to prevent naming conflicts, especially in parallel execution environments. The changes also include enhancements to the test result data models, allowing for more detailed and structured reporting, and optimize data storage by separating monitoring information. These improvements collectively aim to provide a more comprehensive, flexible, and efficient reporting experience for test runs. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request significantly enhances screenshot handling by introducing support for saving screenshots as files instead of just base64 strings. This is a great improvement for performance and report management. The changes include better directory organization for reports, collision avoidance for filenames in parallel execution, and updates across various modules to support screenshot paths. The implementation is thorough and well-thought-out. I've provided a few suggestions to further improve robustness and maintainability.
| timestamp = datetime.datetime.now().strftime('%H%M%S') | ||
| # Use high-precision timestamp and random suffix to avoid collisions in parallel execution | ||
| now = datetime.datetime.now() | ||
| timestamp = now.strftime('%H%M%S') |
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.
The current timestamp format for screenshot filenames has only second-level precision. In scenarios with high-frequency screenshot captures, especially during parallel test execution, this could lead to filenames that don't reflect the true chronological order if multiple screenshots are taken within the same second. Using a more precise timestamp would improve debugging and log analysis.
I suggest including microseconds in the timestamp to ensure unique and correctly ordered filenames.
| timestamp = now.strftime('%H%M%S') | |
| timestamp = now.strftime('%H%M%S_%f') |
| # Store raw monitoring data as a temporary attribute for later saving | ||
| # This allows us to save it separately without modifying the data model | ||
| setattr(result, '_raw_monitoring_data', monitoring_data) |
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.
Using setattr to dynamically add an attribute to a Pydantic model instance can make the code harder to understand and maintain, as the attribute is not part of the model's defined schema. This can lead to issues with static analysis, type checking, and IDE support.
A more robust approach would be to either include _raw_monitoring_data as an optional, private field in the SubTestResult model (e.g., using PrivateAttr from Pydantic) or to return the monitoring data alongside the result object in a tuple from _build_case_result. This would make the data flow more explicit and type-safe.
webqa_agent/executor/case_mode.py
Outdated
| report_dir = report_config.get('report_dir') if report_config else None | ||
| # Handle null, None, empty string, or missing value | ||
| if not report_dir or (isinstance(report_dir, str) and report_dir.strip() == ''): | ||
| # Use default reports/{timestamp}/ directory | ||
| report_dir = f'reports/test_{report_ts}' |
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.
This logic for resolving the report directory is duplicated in webqa_agent/executor/parallel_mode.py (lines 76-81). To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, consider extracting this logic into a shared utility function. This function could take the report configuration and a timestamp as input and return the resolved report directory path.
| token = test_id_var.set(log_context) | ||
|
|
||
| # Set screenshot prefix to avoid filename collisions in parallel execution | ||
| from webqa_agent.actions.action_handler import \ |
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.
可以考虑放在顶部
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.
done
webqa_agent/executor/case_mode.py
Outdated
| os.environ['WEBQA_REPORT_TIMESTAMP'] = report_ts | ||
|
|
||
| # Initialize screenshot directory for this test session | ||
| from webqa_agent.actions.action_handler import ActionHandler |
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.
+1
| token = test_id_var.set(test_config.test_name) | ||
|
|
||
| # Set screenshot prefix to avoid collisions. LangGraph workers will override this with case_id. | ||
| from webqa_agent.actions.action_handler import screenshot_prefix_var |
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.
+1
| token = test_id_var.set(log_context) | ||
|
|
||
| # Set screenshot prefix to avoid filename collisions in parallel execution | ||
| from webqa_agent.actions.action_handler import \ |
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.
+1