Skip to content

Fix driver lifecycle and cookie bugs, update deps, offline test suite (0.6.0) - #221

Merged
lordjabez merged 13 commits into
masterfrom
spruce-up
Oct 1, 2026
Merged

lordjabez merged 13 commits into
masterfrom
spruce-up

Conversation

@lordjabez

Copy link
Copy Markdown
Collaborator

Bug fixes, issue fixes, dependency updates, and an offline test suite. Bumps the version to 0.6.0.

Behavior changes

Bug fixes

  • try_add_cookie re-raised every Selenium error as a bare WebDriverException with the message stripped, so the fallback to a broader cookie domain almost never ran. It now suppresses only cookie-rejection errors.
  • ensure_add_cookie no longer changes the dict you pass in. Its domain check no longer matches substrings ("ample.com" used to count as "example.com").
  • ensure_element(timeout=0) is honored now.
  • Cookie transfers in both directions now keep secure, path and expiry.
  • RequestiumResponse no longer creates a new class for every response.

Dependencies and tooling

  • uv lock --upgrade (selenium 4.40 → 4.50, ruff 0.14 → 0.16, etc.). Runtime lower bounds are unchanged; I checked them by testing against the lowest allowed versions.
  • Added an explicit setuptools [build-system] and PEP 639 license metadata.
  • Dev tools moved from a published dev extra to a PEP 735 dependency group. CI now installs --group dev.
  • The bandit pre-commit hook targeted ^src, which matches nothing in this repo, so it never ran. It now targets requestium/.

Tests (#93)

  • The suite runs fully offline. A single LocalServer fixture serves pages, records requests, and acts as an HTTP forward proxy, so the cookie tests use realistic hostnames without reaching the internet.
  • New tests cover ensure_element states and timeouts, ensure_click DOM effects, driver-side parsing, a Remote driver backed by a local chromedriver service, close/lifecycle, all HTTP verbs, and proxy/User-Agent launch arguments.
  • Local run (macOS, Chrome and Firefox): 360 passed, 0 skipped, 99% coverage.

Docs

  • Fixed README examples that didn't match the API.
  • Documented the new behavior in the README.
  • Added CLAUDE.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01446x2ZH4bs3pKQ6mV84K1a

lordjabez and others added 13 commits October 1, 2026 11:30
- Add explicit setuptools build-system and PEP 639 license metadata
- Move dev tools to a PEP 735 dependency group instead of a published extra
- Bump ruff, bandit, ssort, pre-commit; refresh uv.lock
- Point the bandit pre-commit hook at requestium/ (it matched nothing)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01446x2ZH4bs3pKQ6mV84K1a
- try_add_cookie only suppresses cookie-rejection errors; others propagate
  with their message instead of a bare WebDriverException
- ensure_add_cookie no longer mutates the caller's dict
- Navigate over https for secure cookies (#97)
- Replace substring domain match with an exact/subdomain check
- Honor an explicit timeout=0 in ensure_element
- RequestiumResponse copies the wrapped response's state instead of
  building a new class per response

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01446x2ZH4bs3pKQ6mV84K1a
…to Chrome

- Session.close() (and leaving a with block) quits the driver (#177)
- Give user-supplied drivers the DriverMixin helpers by swapping in a cached
  subclass; the old per-function patching skipped the selector property, so
  xpath/css/re failed on injected drivers including webdriver.Remote (#31)
- Wrap every HTTP verb via request() instead of only get/post/put
- Pass session proxies and a custom User-Agent to Requestium's own Chrome
  at launch; credentialed proxies are skipped with a warning (#96, #55, #37)
- Carry secure/path/expiry when transferring cookies in both directions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01446x2ZH4bs3pKQ6mV84K1a
Fix examples that didn't match the API (keyword-only Session, missing
comma, JS booleans), note Selenium Manager, and document close/context
manager, Remote drivers, proxy/User-Agent carry-over, and https for
secure cookies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01446x2ZH4bs3pKQ6mV84K1a
- Local HTTP server and forward proxy fixture so cookie tests no longer
  hit google.com/example.com
- New tests for ensure_element states and timeouts, ensure_click DOM
  effects, driver-side parsing, and a Remote driver backed by a local
  chromedriver service (#31)
- Collapse duplicated ensure_element_by_* and session init tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01446x2ZH4bs3pKQ6mV84K1a
Ruff 0.16 formats Python code fences in Markdown, so pre-commit
rewrites these.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01446x2ZH4bs3pKQ6mV84K1a
Replace four ad-hoc HTTP servers with a single conftest LocalServer
(forward proxy, request log, optional TLS listener), merge the
agent-split cookie and session test files into functional modules
(add_cookie, cookies, session, proxy, user_agent), and drop duplicate
tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01446x2ZH4bs3pKQ6mV84K1a
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01446x2ZH4bs3pKQ6mV84K1a
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01446x2ZH4bs3pKQ6mV84K1a
Chrome tries http:// navigations over https first. With balanced
HTTPS-First mode auto-enabled (e.g. Chrome 152 on CI runners) it does
not fall back to http when the CONNECT through the test proxy fails,
so every proxied page came up blank and cookie tests failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01446x2ZH4bs3pKQ6mV84K1a
Dependabot bumped init/analyze but left autobuild and upload-sarif on
v4.31.10, and CodeQL refuses to run with mismatched versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01446x2ZH4bs3pKQ6mV84K1a
Comment thread tests/conftest.py
if certfile:
context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain(certfile)
self.socket = context.wrap_socket(self.socket, server_side=True)
Comment thread tests/test_add_cookie.py
def test_secure_cookie_navigates_over_https(secure_chrome: DriverMixin, https_server: LocalServer) -> None:
secure_chrome.ensure_add_cookie({"name": "sec", "value": "1", "domain": "app.secure.com", "secure": True})

assert secure_chrome.current_url.startswith("https://app.secure.com")
Comment thread tests/test_add_cookie.py
def test_insecure_cookie_navigates_over_http(chrome: DriverMixin, server: LocalServer) -> None:
chrome.ensure_add_cookie({"name": "plain", "value": "1", "domain": "plain.example.com"})

assert chrome.current_url.startswith("http://plain.example.com")
Comment thread tests/test_add_cookie.py
chrome.ensure_add_cookie({"name": "sub", "value": "1", "domain": "ample.com"})

assert ("GET", "ample.com", "/") in server.requests()
assert chrome.current_url.startswith("http://ample.com")
Comment thread tests/test_add_cookie.py
chrome.ensure_add_cookie({"name": "parent", "value": "1", "domain": ".example.com"})

assert len(server.requests()) == before
assert chrome.current_url.startswith("http://sub.example.com")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants