Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Replace Selenium with Playwright for browser automation#1153

Closed
jcroy wants to merge 2 commits intofeder-cr:mainfrom
jcroy:feat/playwright-migration
Closed

Replace Selenium with Playwright for browser automation#1153
jcroy wants to merge 2 commits intofeder-cr:mainfrom
jcroy:feat/playwright-migration

Conversation

@jcroy
Copy link
Copy Markdown

@jcroy jcroy commented Mar 19, 2026

Summary

  • Replaced Selenium/ChromeDriver/undetected-chromedriver with Playwright for all browser automation (PDF generation, page navigation, DOM access)
  • Added monkey-patch module (patch_lib_resume_builder.py) to redirect the external lib_resume_builder_AIHawk library's Selenium calls to Playwright at runtime
  • Fixed a runtime crash where the monkey-patch module created duplicate Playwright instances — now reuses the shared browser pool from chrome_utils
  • Cleaned up Selenium-specific logging, config, and dependencies

Changes

  • chrome_utils.py — Rewrote with Playwright sync API, browser pooling, native PDF generation
  • resume_facade.py — Migrated driver.get()goto(), find_element()locator(), quit()close()
  • patch_lib_resume_builder.py — New file; monkey-patches lib_resume_builder_AIHawk to use Playwright
  • main.py — Removed Selenium imports, added patch application
  • logging.py — Removed Selenium-specific logger init
  • config.py — Removed LOG_SELENIUM_LEVEL
  • requirements.txt — Removed selenium, webdriver-manager, undetected-chromedriver; added playwright>=1.40.0

Test plan

  • Browser initialization and page creation
  • Browser pool reuse (same instance returned)
  • Page navigation and DOM content extraction
  • HTML → PDF conversion (valid PDF with correct magic bytes)
  • Input validation (rejects empty/whitespace HTML)
  • Monkey-patch functions (_create_driver_playwright, _html_to_pdf_from_file)
  • Real URL navigation (example.com)
  • apply_patch() executes without error
  • All 19/19 e2e tests pass

🤖 Generated with Claude Code

jcroy and others added 2 commits March 19, 2026 14:49
Selenium + ChromeDriver + undetected-chromedriver were the only browser
automation deps and were used for two things: scraping job pages and
converting HTML to PDF via CDP. Playwright handles both natively with
a simpler API (page.pdf(), page.goto()) and easier install on WSL.

Changes:
- Rewrite src/utils/chrome_utils.py to use Playwright sync API
- Update resume_facade.py to use Playwright page methods
- Remove Selenium imports from main.py and src/logging.py
- Add monkey-patch for lib_resume_builder_AIHawk's Selenium usage
- Swap selenium/webdriver-manager/undetected-chromedriver for playwright
  in requirements.txt
- Bump Levenshtein>=0.26.0 for Python 3.13 compat
- Switch default LLM model to gpt-5-mini

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
_create_driver_playwright was spinning up a new sync_playwright() instance,
which conflicts with the already-running one from chrome_utils at runtime.
Now reuses the shared browser pool via _get_browser().

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jcroy jcroy closed this Mar 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant