Files
PartDB_Helper_App/ACCEPT_JOBS_README.md

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:

  1. Navigate to your import job page (or you can navigate there manually)
  2. Find all selectable "Update Part" buttons (only btn btn-primary without the disabled class)
  3. 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
  4. Repeat until no more enabled "Update Part" buttons are found

How to Use

  1. Run the main application: python main.py
  2. On the home page, click the "Accept Import Jobs" button in the Tools section
  3. A browser window will open
  4. When prompted, navigate to the import job page where the "Update part" buttons are
  5. Press Enter in the console to start the automation
  6. Watch as the automation processes each job
  7. When complete, press Enter to close the browser

Option 2: Standalone Script

  1. Open PowerShell/Terminal
  2. Run: python workflows\accept_import_jobs.py
  3. 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 disabled class (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 (without disabled)
  • The buttons must be visible, enabled, and not have the disabled class
  • 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.py if 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.