{"record":{"id":"cc433c8f4f24afb8","repo":"jackwener/OpenCLI","slug":"category-click-failed","errorCode":null,"errorMessage":"Category click failed.","messagePattern":"Category click failed\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/trae-solo/skill.js","lineNumber":203,"sourceCode":"      const tag = Array.from(document.querySelectorAll('.marketplace-tag'))\n        .find((t) => t.offsetParent && (t.textContent || '').trim().toLowerCase().includes(${nameJson}));\n      if (!tag) return { ok: false, reason: 'Category not found.' };\n      const r = tag.getBoundingClientRect();\n      const init = {\n        bubbles: true, cancelable: true, button: 0, buttons: 1,\n        clientX: Math.round(r.left + r.width / 2),\n        clientY: Math.round(r.top + r.height / 2),\n      };\n      tag.dispatchEvent(new PointerEvent('pointerdown', { ...init, pointerType: 'mouse' }));\n      tag.dispatchEvent(new MouseEvent('mousedown', init));\n      tag.dispatchEvent(new PointerEvent('pointerup', { ...init, pointerType: 'mouse' }));\n      tag.dispatchEvent(new MouseEvent('mouseup', init));\n      tag.dispatchEvent(new MouseEvent('click', init));\n      await wait(700);\n      return { ok: true, chosen: (tag.textContent || '').trim() };\n    })()`);\n        if (!switchRes?.ok) {\n            throw new CommandExecutionError(switchRes?.reason || 'Category click failed.', SESSION_HINT);\n        }\n\n        const items = await page.evaluate(`(function() {\n      const cards = Array.from(document.querySelectorAll('.marketplace-card-v2')).filter((c) => c.offsetParent);\n      return cards.map((c, i) => {\n        const logo = c.querySelector('.skill-logo-svg');\n        const name = (logo && logo.getAttribute('aria-label')) || '';\n        const full = (c.innerText || '').replace(/\\\\s+/g, ' ').trim();\n        let desc = full;\n        if (name && desc.startsWith(name)) desc = desc.slice(name.length).trim();\n        return { index: i + 1, name: name || full.split(' ')[0], description: desc.slice(0, 200) };\n      });\n    })()`);\n        const limit = Number.isInteger(kwargs.limit) && kwargs.limit > 0 ? kwargs.limit : 100;\n        return ((items || []).slice(0, limit)).map((r) => ({ Index: r.index, Name: r.name, Description: r.description }));\n    },\n});\n","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trae-solo/skill.js#L185-L221","documentation":"This CommandExecutionError is thrown when an in-page browser script that dispatches synthetic mouse events (mouseup/click) to a marketplace category tag fails to report ok:true. The wrapper executed via page.evaluate did not complete successfully or returned a failure reason, so the CLI cannot proceed to scrape '.marketplace-card-v2' cards. It means the simulated category click did not land on a usable element (selector drift, hidden element, or navigation away).","triggerScenarios":"Running the marketplace category/listing command when: the category tag selector changed in the Trae marketplace UI, the tag is not visible/clickable (offsetParent falsy), the evaluate block throws or returns {ok:false,reason:...}, or the 700ms wait is not enough and a follow-up check fails.","commonSituations":"Marketplace UI updated and renamed CSS classes; clicking an already-selected category re-renders and invalidates the node; slow network leaves the tag inside a loading skeleton; automation runs headless where the tag is display:none.","solutions":["Re-run with a fresh page; transient render timing often resolves it.","Verify the category tag selector still exists in the current marketplace DOM and update the page.evaluate snippet in skill.js if renamed.","Increase the post-click wait (700ms) or poll for '.marketplace-card-v2' visibility instead of fixed sleep.","Check switchRes.reason in the thrown message for the specific failure and handle that case (e.g. re-navigate to the marketplace page first)."],"exampleFix":"// before\nawait wait(700);\nreturn { ok: true, chosen: (tag.textContent || '').trim() };\n// after\nfor (let i = 0; i < 10; i++) {\n  await wait(200);\n  if (document.querySelector('.marketplace-card-v2')) break;\n}\nreturn { ok: !!document.querySelector('.marketplace-card-v2'), chosen: (tag.textContent || '').trim() };","handlingStrategy":"retry","validationCode":"const ready = await page.evaluate(`!!document.querySelector('.marketplace-card-v2, .marketplace-category-tag')`);\nif (!ready) throw new Error('Marketplace UI not ready');","typeGuard":"function isSwitchOk(res) { return !!res && typeof res === 'object' && res.ok === true && typeof res.chosen === 'string'; }","tryCatchPattern":"try {\n  const res = await runCategorySwitch(page);\n  if (!isSwitchOk(res)) throw new CommandExecutionError(res?.reason || 'Category click failed.');\n} catch (e) {\n  // retry once with fresh page / longer poll before surfacing\n}","preventionTips":["Poll for '.marketplace-card-v2' visibility instead of a fixed 700ms wait","Assert tag visibility (offsetParent) before dispatching click events","Snapshot the marketplace DOM in CI to detect selector drift early","Re-navigate to the marketplace page before retrying a failed click"],"tags":["browser-automation","dom-selector","puppeteer"],"backgroundTag":"dom-selector-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}