Spaces:
Running
Running
Screenshot Setup Guide for ChatUI Helper Documentation
This guide explains how to use Playwright to capture screenshots for the ChatUI Helper documentation.
Installation
- Install Playwright and its dependencies:
pip install -r requirements.txt
playwright install chromium
Usage
Capturing Local App Screenshots
- Start the ChatUI Helper app locally:
python app.py
- In a new terminal, run the screenshot capture:
# Capture all local app screenshots
python capture_docs_screenshots.py local
# Or capture all screenshots from the main script
python capture_screenshots.py
Capturing HuggingFace Screenshots
For HuggingFace deployment screenshots, you can either:
- Use placeholder URLs:
python capture_docs_screenshots.py huggingface
- Or provide actual space details:
python capture_docs_screenshots.py huggingface your-username your-space-name
Capturing Specific Screenshots
To capture a single screenshot:
python capture_screenshots.py main_interface
Screenshot Configurations
Local App Screenshots (capture_screenshots.py
)
main_interface
- Full app interfaceconfig_tab
- Configuration tabtemplate_dropdown
- Template selectionpreview_tab
- Preview tabpreview_chat_example
- Chat exampledocs_tab
- Documentation tabconfig_system_prompt
- System configurationconfig_api_section
- API configurationgenerate_button
- Generate button
Documentation Screenshots (capture_docs_screenshots.py
)
- Local app documentation views
- HuggingFace Spaces deployment steps
- Settings and configuration screens
Updating support_docs.py
After capturing new screenshots, update the image references in support_docs.py
:
- Replace placeholder image names (img1.png, img2.png, etc.) with descriptive names
- Update the
gr.Image
components to reference the new screenshots - Ensure all image paths are correct
Screenshot Best Practices
- Consistency: Use the same viewport size (1280x800) for all screenshots
- Quality: Device scale factor is set to 2 for high-quality images
- Wait Times: Adjust wait times if animations haven't completed
- Headless Mode: Set
headless=True
in the browser launch for automated captures
Troubleshooting
Common Issues
- Timeout errors: Increase wait times in the configuration
- Element not found: Update selectors if the UI has changed
- Network errors: Add
wait_until='networkidle'
to page navigation
Debug Mode
Run with visible browser:
browser = await p.chromium.launch(headless=False)
Updating Selectors
If the UI changes, update selectors in the configuration:
- Use browser DevTools to find new selectors
- Test selectors in the browser console first
- Use data-testid attributes when available
Maintenance
Regularly review and update:
- Screenshot configurations when UI changes
- Image references in support_docs.py
- Wait times if performance changes
- Selectors if Gradio updates change the DOM structure