3.6 KiB
3.6 KiB
Bulk Import Job Acceptance Automation
This feature automates the acceptance of bulk import jobs in PartDB.
What It Does
The automation will:
- Navigate to your import job page (or you can navigate there manually)
- Find all selectable "Update Part" buttons (only
btn btn-primarywithout thedisabledclass) - For each button:
- Click the button and wait for the page to load (stays on same page)
- Click "Save" and wait for the page to load
- Click "Save" again and wait for the page to load
- Click "Complete" to finish the job
- Repeat until no more enabled "Update Part" buttons are found
How to Use
Option 1: From the UI (Recommended)
- Run the main application:
python main.py - On the home page, click the "Accept Import Jobs" button in the Tools section
- A browser window will open
- When prompted, navigate to the import job page where the "Update part" buttons are
- Press Enter in the console to start the automation
- Watch as the automation processes each job
- When complete, press Enter to close the browser
Option 2: Standalone Script
- Open PowerShell/Terminal
- Run:
python workflows\accept_import_jobs.py - Follow the same steps as above
Option 3: With Direct URL
If you know the exact URL of the import job page, you can modify the script:
from workflows.accept_import_jobs import run_accept_import_jobs
# Provide the direct URL
run_accept_import_jobs("https://partdb.neutronservices.duckdns.org/en/import/jobs/123")
Configuration
In config.py, you can adjust:
# Maximum number of jobs to process in one run (prevents infinite loops)
ACCEPT_JOBS_MAX_ITERATIONS = 100
# Delay between job attempts (seconds)
ACCEPT_JOBS_RETRY_DELAY = 1.0
# Whether to run browser in headless mode
HEADLESS_CONTROLLER = False # Set to True to hide the browser window
Button Detection
The automation specifically looks for "Update Part" buttons that:
- Have the class
btn btn-primary(indicating a clickable button) - Do NOT have the
disabledclass (which would make them unclickable)
This ensures only valid, actionable import jobs are processed and disabled buttons are skipped.
Button texts detected:
- "Update Part"
- "Update part"
And will click Save/Complete buttons with these texts:
- "Save"
- "Save changes"
- "Complete"
Important: The automation filters out any buttons with class="btn btn-primary disabled" to avoid clicking non-actionable buttons.
Troubleshooting
No buttons found
- Make sure you're on the correct page with import jobs
- Check that there are "Update Part" buttons with class
btn btn-primary(withoutdisabled) - The buttons must be visible, enabled, and not have the
disabledclass - Only jobs that are ready to process will have enabled buttons
Automation stops early
- Check the console output for error messages
- Some jobs might have different button text or layout
- You can adjust the XPath selectors in
provider/selenium_flow.pyif needed
Browser closes immediately
- Make sure you press Enter only when you're on the correct page
- Check that you're logged in to PartDB
Statistics
After completion, you'll see:
- Number of jobs successfully processed
- Number of jobs that failed
- Total time taken
Technical Details
The automation uses:
- Selenium WebDriver for browser automation
- Firefox as the default browser (with Chrome fallback)
- Robust element detection that handles stale elements and page reloads
- Automatic retry logic for clicking buttons
The main function is accept_bulk_import_jobs() in provider/selenium_flow.py.