Skip to content

fix: follow site drift (VoteBridgeNew .jsp→.xhtml and btnSubmit CSS scope) (#115)#116

Open
nishimaki wants to merge 2 commits intohmasdev:mainfrom
nishimaki:pr/site-drift
Open

fix: follow site drift (VoteBridgeNew .jsp→.xhtml and btnSubmit CSS scope) (#115)#116
nishimaki wants to merge 2 commits intohmasdev:mainfrom
nishimaki:pr/site-drift

Conversation

@nishimaki
Copy link
Copy Markdown

Summary

Fixes two independent drifts that break the entire voting flow against
the current live site. Details and reproduction are in #115.

  • Drift 1: VoteBridgeNew.jspVoteBridgeNew.xhtml
    (get_bet_limit / login redirected to the SP error page).
    pyjpboatrace/const.py, 1 line.
  • Drift 2: By.CLASS_NAME, 'btnSubmit' is ambiguous on the current
    DOM (matches hidden password-change forms first). Scoped to
    By.CSS_SELECTOR, '.inputCompletion .btnSubmit a' and added a
    WebDriverWait for the confirmation page's id=pass.
    pyjpboatrace/operator/better.py, 9/-3.

Both commits are independently reviewable.

Test plan

  • get_bet_limit() returns the correct numeric balance on the live
    site (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.
  • Unit tests — not added here because the existing better.py
    tests 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 I
    rely 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.
  • No behavior change when the login URL / DOM revert: the CSS selector
    .inputCompletion .btnSubmit a is strictly more specific than
    .btnSubmit and should still match the intended button, while the
    WebDriverWait only adds a few milliseconds on the happy path.

Closes #115

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.
@hmasdev hmasdev requested review from Copilot and hmasdev and removed request for hmasdev April 23, 2026 14:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.jsp to VoteBridgeNew.xhtml.
  • Disambiguate the bet “complete input” click by switching from By.CLASS_NAME, 'btnSubmit' to a scoped CSS selector.
  • Add an explicit WebDriverWait for 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.

Comment on lines 162 to +179
@@ -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'))
)
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
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.

[BUG] Voting flow broken on current site (VoteBridgeNew.jsp 404 and btnSubmit selector collision)

2 participants