A Python tool that extracts Figma design data via API and generates comprehensive BDD (Behavior Driven Development) test scenarios using AWS Bedrock AI services.
- Figma API Integration: Extract design data from Figma files with dev seat access
- AWS Bedrock Integration: Generate intelligent BDD scenarios using Claude AI
- Multiple Output Formats: Generate documents in Markdown, HTML, PDF, and JSON formats
- SSL Validation: Configurable SSL certificate verification
- Modular Commands: Separate commands for extraction and generation
- Multiple Scenario Types: Functional, UI, Accessibility, and Performance testing scenarios
- Python 3.8 or higher
- Figma account with dev seat access
- AWS account with Bedrock access
- Internet connection for API calls
- Clone or setup the project:
cd /Users/ghanthan/PycharmProjects/FigmaToBdd- Install dependencies:
pip install -r requirements.txt- Configure environment variables:
Copy the
.envfile and update with your credentials (see setup instructions below).
-
Get Figma Personal Access Token:
- Go to Figma Developers
- Click "Get personal access token"
- Log in to your Figma account
- Generate a new personal access token
- Copy the token
-
Get Figma File ID:
- Open your Figma file in the browser
- Copy the file ID from the URL:
https://www.figma.com/file/FILE_ID/... - The FILE_ID is the long string after
/file/
-
Update .env file:
FIGMA_ACCESS_TOKEN=your_figma_token_here
FIGMA_FILE_ID=your_file_id_here-
Create AWS IAM User:
- Go to AWS IAM Console
- Create a new user or use existing user
- Attach the policy:
AmazonBedrockFullAccess
-
Generate Access Keys:
- In IAM, go to Users β Your User β Security credentials
- Create access key for CLI/API usage
- Copy Access Key ID and Secret Access Key
-
Enable Bedrock Models:
- Go to AWS Bedrock Console
- Navigate to "Model access"
- Request access to Anthropic Claude models (claude-3-sonnet recommended)
- Wait for approval (usually instant for Claude models)
-
Update .env file:
AWS_ACCESS_KEY_ID=your_access_key_here
AWS_SECRET_ACCESS_KEY=your_secret_key_here
AWS_REGION=us-east-1For production environments:
VERIFY_SSL=trueFor development/testing (if you encounter SSL issues):
VERIFY_SSL=falsepython main.py setuppython main.py test-connection# Extract design data and save as JSON
python main.py extract-figma -f YOUR_FIGMA_FILE_ID
# With custom output filename
python main.py extract-figma -f YOUR_FIGMA_FILE_ID -o my_design_data
# Override token from command line
python main.py extract-figma -f YOUR_FIGMA_FILE_ID -t YOUR_TOKEN# Generate functional BDD scenarios
python main.py generate-bdd -i figma_data.json
# Generate specific scenario types
python main.py generate-bdd -i figma_data.json --type ui
python main.py generate-bdd -i figma_data.json --type accessibility
python main.py generate-bdd -i figma_data.json --type performance
# Generate in specific format
python main.py generate-bdd -i figma_data.json --format pdf
python main.py generate-bdd -i figma_data.json --format html
python main.py generate-bdd -i figma_data.json --format all# Complete workflow: extract + generate
python main.py full-pipeline -f YOUR_FIGMA_FILE_ID
# With specific options
python main.py full-pipeline -f YOUR_FIGMA_FILE_ID --type functional --format all| Parameter | Description | Options |
|---|---|---|
-f, --file-id |
Figma file ID | Required for extraction |
-i, --input |
Input JSON file | Required for generation |
-o, --output |
Output filename | Default: varies by command |
-T, --type |
Scenario type | functional, ui, accessibility, performance |
-F, --format |
Output format | markdown, pdf, html, all |
-t, --token |
Figma token override | Overrides .env setting |
--no-ssl-verify |
Disable SSL verification | Flag for SSL issues |
FigmaToBdd/
βββ main.py # CLI application entry point
βββ figma_client.py # Figma API client
βββ bedrock_client.py # AWS Bedrock client
βββ document_generator.py # Document generation utilities
βββ requirements.txt # Python dependencies
βββ .env # Environment configuration
βββ output/ # Generated documents (created automatically)
βββ README.md # This file
The tool generates the following types of files:
figma_design_data.json- Raw extracted Figma data{filename}_data.json- Processed design data
{filename}.md- Markdown format with BDD scenarios{filename}.html- HTML document with styling{filename}.pdf- PDF document for sharing/printing
output/
βββ figma_design_data.json
βββ bdd_scenarios.md
βββ bdd_scenarios.html
βββ bdd_scenarios.pdf
βββ bdd_scenarios_data.json
- Business logic validation
- User workflow testing
- Data flow scenarios
- Integration testing
- Element visibility and positioning
- Responsive design behavior
- Visual consistency checks
- Interaction feedback
- WCAG 2.1 compliance
- Keyboard navigation
- Screen reader compatibility
- Color contrast validation
- Page load time scenarios
- Resource optimization
- API response times
- Mobile performance
-
SSL Certificate Errors:
# Use --no-ssl-verify flag or set VERIFY_SSL=false in .env python main.py extract-figma -f YOUR_FILE_ID --no-ssl-verify -
Figma API Token Issues:
- Verify token is valid and has not expired
- Ensure you have access to the Figma file
- Check if the file ID is correct
-
AWS Bedrock Access:
- Verify IAM permissions include BedrockFullAccess
- Ensure Claude models are enabled in your AWS region
- Check AWS credentials are valid
-
Missing Dependencies:
pip install -r requirements.txt
| Error | Solution |
|---|---|
| "Figma access token is required" | Set FIGMA_ACCESS_TOKEN in .env |
| "AWS credentials are required" | Set AWS keys in .env |
| "Failed to fetch Figma file" | Check file ID and token |
| "Bedrock API error" | Verify AWS permissions and model access |
- New Scenario Types: Extend
BedrockClient.generate_test_scenarios() - New Output Formats: Add methods to
DocumentGenerator - New Figma Elements: Extend
FigmaClient._process_element()
# Test individual components
python -c "from figma_client import FigmaClient; print('Figma client imported successfully')"
python -c "from bedrock_client import BedrockClient; print('Bedrock client imported successfully')"
python -c "from document_generator import DocumentGenerator; print('Document generator imported successfully')"- Prepare your Figma file with clear naming and organization
- Set up API credentials following the setup instructions
- Extract design data:
python main.py extract-figma -f YOUR_FILE_ID -o my_app_design
- Review the extracted JSON to ensure all elements are captured
- Generate BDD scenarios:
python main.py generate-bdd -i my_app_design.json --type functional --format all
- Review generated documents and customize as needed
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For issues and questions:
- Check the troubleshooting section
- Review error messages carefully
- Verify API credentials and permissions
- Test with a simple Figma file first
Happy Testing! π