{"record":{"id":"7b21cf7abd71df2c","repo":"babalae/better-genshin-impact","slug":"materialtype","errorCode":null,"errorMessage":"未能选择材料筛选类型：{materialType}","messagePattern":"未能选择材料筛选类型：(.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.cs","lineNumber":279,"sourceCode":"    /// </summary>\n    /// <returns>处于合成界面时返回 true。</returns>\n    private bool IsInCraftingUi()\n    {\n        return ContainsText(Rect1080(40, 960, 720, 105), \"筛选\")\n               && ContainsText(Rect1080(0, 0, 260, 95), \"合成\");\n    }\n\n    /// <summary>\n    /// 选择材料筛选类型，失败时抛出异常。\n    /// </summary>\n    /// <param name=\"materialType\">材料筛选类型。</param>\n    /// <returns>异步任务。</returns>\n    /// <exception cref=\"InvalidOperationException\">未找到或无法点击筛选类型时抛出。</exception>\n    private async Task SelectMaterialType(string materialType)\n    {\n        if (!await TrySelectMaterialType(materialType))\n        {\n            throw new InvalidOperationException($\"未能选择材料筛选类型：{materialType}\");\n        }\n    }\n\n    /// <summary>\n    /// 在筛选弹窗中选择指定材料类型。\n    /// </summary>\n    /// <param name=\"materialType\">材料筛选类型。</param>\n    /// <returns>选择成功时返回 true。</returns>\n    private async Task<bool> TrySelectMaterialType(string materialType)\n    {\n        try\n        {\n            var confirmation = await Page.GetByText(materialType, Rect1080(165, 1000, 279, 34)).TryWaitFor(300);\n            if (confirmation.Count > 0)\n            {\n                return true;\n            }\n            await Page.GetByText(\"筛选\", Rect1080(90, 1000, 60, 33)).Click(3000);","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.cs#L261-L297","documentation":"Thrown as InvalidOperationException by CraftMaterialTask.SelectMaterialType when TrySelectMaterialType returns false, meaning the filter-type selection popup either timed out or the expected materialType text button was not found/clickable. The method first tries a quick confirmation, then opens the filter popup and clicks the category; failure at either step (caught TimeoutException → return false) triggers this.","triggerScenarios":"The materialType string passed does not match any visible text button in the filter popup (wrong name, wrong language). The popup did not open due to UI lag. The click landed but the selection confirmation did not appear within the timeout.","commonSituations":"The materialType value is from an outdated item.csv that doesn't match the current game's filter category names. Game UI language mismatch. Game animation/loading delay caused the popup to not render in time. The crafting UI layout changed in a game update.","solutions":["Verify the materialType string exactly matches a visible filter category name in the current game version.","Increase the timeout passed to GetByText(...).Click() or add retry logic.","Ensure the game UI language matches the expected Chinese category names."],"exampleFix":"null","handlingStrategy":"retry","validationCode":"null","typeGuard":"null","tryCatchPattern":"for (int attempt = 0; attempt < 3; attempt++)\n{\n    try { await task.Start(ct); break; }\n    catch (InvalidOperationException ex) when (ex.Message.Contains(\"材料筛选类型\")) { /* wait, retry */ } }","preventionTips":["Verify the materialType string matches the game's current filter category names.","Increase click timeouts or add retry logic for UI lag."],"tags":["crafting","ui-interaction","ocr","timeout"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}