babalae/better-genshin-impact · error · PartySetupFailedException

未能打开队伍选择页面

Error message

未能打开队伍选择页面

What it means

Once on the party-view UI, SwitchPartyTask.Start clicks the party-choose button (partyViewBtn) and waits via NewRetry.WaitForElementAppear for the 'PartyBtnDelete' element to appear (4 retries x 500ms). If the party-selection menu does not open, it throws PartySetupFailedException.

Source

Thrown at BetterGenshinImpact/GameTask/Common/Job/SwitchPartyTask.cs:134

            {
                Simulation.SendInput.Keyboard.KeyPress(User32.VK.VK_ESCAPE);
                await Delay(500, ct);
                await _returnMainUiTask.Start(ct);
            }

            return true;
        }

        var menu = await NewRetry.WaitForElementAppear(
            ElementRecognition.Get("PartyBtnDelete"),
            () => partyViewBtn.Click(),// 点击队伍选择按钮
            ct,
            4,
            500
        );
        if (!menu)
        {
            throw new PartySetupFailedException("未能打开队伍选择页面");
        }

        ImageRegion? switchRa = null;
        Region? partyDeleteBtn = null;
        using (var ocrRa = CaptureToRectArea())
        {
            var openPartyChooseSuccess = await NewRetry.WaitForAction(() =>
            {
                switchRa = ocrRa;
                partyDeleteBtn = switchRa.Find(ElementRecognition.Get("PartyBtnDelete", switchRa));
                return partyDeleteBtn.IsExist();
            }, ct, 5);

            if (!openPartyChooseSuccess || switchRa == null || partyDeleteBtn == null)
            {
                throw new PartySetupFailedException("未能打开队伍配置界面");
            }
        }

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Confirm ElementRecognition.Get('PartyBtnDelete') template matches the current party-selection menu and capture scale.
  2. Verify partyViewBtn was found at the correct location and the click coordinates are valid.
  3. Increase the 4x500ms retry budget if the menu opens slowly.
  4. Ensure the game window has input focus and no overlay intercepts the click.
Defensive patterns

Strategy: try-catch

Try / catch

try { await partyTask.Start(partyName, ct); }
catch (PartySetupFailedException ex) when (ex.Message == "未能打开队伍选择页面")
{ _logger.LogError(ex, "队伍选择页面未打开:检查 PartyBtnChooseView 点击坐标与 PartyBtnDelete 模板"); }

Prevention

When it happens

Trigger: The current team is not already the target, so it calls NewRetry.WaitForElementAppear(ElementRecognition.Get('PartyBtnDelete'), () => partyViewBtn.Click(), ct, 4, 500); the element never appears so WaitForElementAppear returns false.

Common situations: partyViewBtn.Click() missed (element moved/scale drift); the party-selection menu failed to open due to game state; ElementRecognition template 'PartyBtnDelete' no longer matches the current UI; the click was swallowed (input focus); a slow menu exceeded the 4x500ms budget.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/da88ddb5ec5fea3e. Report an issue: GitHub.