fix: follow site drift (VoteBridgeNew .jsp→.xhtml and btnSubmit CSS scope) (#115)#116
fix: follow site drift (VoteBridgeNew .jsp→.xhtml and btnSubmit CSS scope) (#115)#116nishimaki wants to merge 2 commits intohmasdev:mainfrom
Conversation
boatrace.jp migrated the vote bridge endpoint from VoteBridgeNew.jsp to VoteBridgeNew.xhtml (JSF). The old URL now redirects to a SP error page (sp/ibm/sliphttp/signless.jsp), causing TimeoutException in get_bet_limit() and the entire betting flow. Verified with get_bet_limit() returning a numeric balance on the real site. Login form, currentBetLimitAmount element, and PC flow are otherwise unchanged.
The bare `By.CLASS_NAME, 'btnSubmit'` matched hidden `btnSubmit` elements belonging to password-change sub-forms (`<li class="btn btnSubmit">`) before the real "投票入力完了" button (`<div class="inputCompletion"><div class="btnSubmit">`). As a result the vote flow silently failed to navigate to the confirmation page, and the following `find_element(By.ID, 'pass')` raised NoSuchElementException. Fix: - Use `By.CSS_SELECTOR, '.inputCompletion .btnSubmit a'` to target the correct button unambiguously. - Wait for `id=pass` on the confirmation page with WebDriverWait to tolerate the navigation delay. Verified against the live site with a real 100-yen trifecta bet: the balance decreased by 100 yen and the bet appeared in the vote history.
There was a problem hiding this comment.
Pull request overview
Fixes two live-site drifts that currently break the Selenium-based voting flow (login/balance fetch and bet submission).
Changes:
- Update the vote bridge endpoint from
VoteBridgeNew.jsptoVoteBridgeNew.xhtml. - Disambiguate the bet “complete input” click by switching from
By.CLASS_NAME, 'btnSubmit'to a scoped CSS selector. - Add an explicit
WebDriverWaitfor the bet confirmation page (id='pass') before entering amount/password and submitting.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
pyjpboatrace/const.py |
Updates the hardcoded vote bridge URL to the current .xhtml endpoint. |
pyjpboatrace/operator/better.py |
Fixes submit-button selection ambiguity and waits for confirmation-page DOM before continuing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -170,7 +173,10 @@ def __bet( | |||
| f'but your current deposit is {limit}.' | |||
| ) | |||
|
|
|||
| # confirmation | |||
| # confirmation page — wait for the betconf DOM to appear | |||
| WebDriverWait(self._driver, timeout).until( | |||
| EC.presence_of_element_located((By.ID, 'pass')) | |||
| ) | |||
There was a problem hiding this comment.
This change alters the Selenium calls made by __bet (switching the submit click from By.CLASS_NAME, 'btnSubmit' to a CSS selector, and adding a WebDriverWait that will call find_element(By.ID, 'pass')). The unit test tests/operator/test_better.py::test_betting_operator_do currently asserts the old (By.CLASS_NAME, 'btnSubmit') call and the previous call order, so it will fail unless updated to expect the new selector and the additional pass lookup triggered by the wait.
Summary
Fixes two independent drifts that break the entire voting flow against
the current live site. Details and reproduction are in #115.
VoteBridgeNew.jsp→VoteBridgeNew.xhtml(
get_bet_limit/ login redirected to the SP error page).pyjpboatrace/const.py, 1 line.By.CLASS_NAME, 'btnSubmit'is ambiguous on the currentDOM (matches hidden password-change forms first). Scoped to
By.CSS_SELECTOR, '.inputCompletion .btnSubmit a'and added aWebDriverWaitfor the confirmation page'sid=pass.pyjpboatrace/operator/better.py, 9/-3.Both commits are independently reviewable.
Test plan
get_bet_limit()returns the correct numeric balance on the livesite (verified twice: before and after deposit).
bet(stadium=14, race=11, trifecta_betting_dict={'1-2-3': 100})succeeds end-to-end against the live site, balance decreases by
100 yen, and the bet appears in the official vote history.
better.pytests appear to be Selenium integration tests. Happy to add
mock-based unit tests for the new CSS selector in a follow-up
commit if you prefer a specific style.
Notes
deposit()/withdraw()paths are not covered in this PR because Irely on manual web-UI deposits in my own operation. They may still
work unchanged once Drift 1 is fixed, but I have not verified them.
.inputCompletion .btnSubmit ais strictly more specific than.btnSubmitand should still match the intended button, while theWebDriverWaitonly adds a few milliseconds on the happy path.Closes #115