jackwener/OpenCLI · error · CliError

SELECTOR

SELECTOR

Error message

Could not find element: 闲鱼聊天输入框

What it means

selectorError thrown when the Xianyu reply flow's extracted chat state has can_input=false — no usable chat input box was found for the conversation. Like error 5431 but in the auto-reply (reply.js) flow.

Source

Thrown at clis/xianyu/reply.js:57

        const url = hasIds ? buildChatUrl(itemId, userId) : '';
        if (hasIds) {
            await page.goto(url);
        } else {
            if (!page.getCurrentUrl || !/https:\/\/www\.goofish\.com\/im\b/.test(await page.getCurrentUrl())) {
                await page.goto('https://www.goofish.com/im');
            }
        }
        await page.wait(2);
        if (rank > 0) {
            requireClickResult(await page.evaluate(buildClickInboxConversationEvaluate(rank - 1)), 'reply rank click');
            await page.wait(2);
        }
        const state = requireEvaluateObject(await page.evaluate(buildExtractChatStateEvaluate()), 'reply');
        if (state?.requiresAuth) {
            throw new AuthRequiredError('www.goofish.com', 'Xianyu reply requires a logged-in browser session');
        }
        if (!state?.can_input) {
            throw selectorError('闲鱼聊天输入框', '未找到可用的聊天输入框,请确认该会话页已正确加载');
        }
        const sent = requireEvaluateObject(await page.evaluate(buildSendMessageEvaluate(text)), 'reply send');
        if (!sent?.ok) {
            throw new CommandExecutionError(`Xianyu reply did not observe the sent message: ${sent?.reason || 'unknown-reason'}`);
        }
        await page.wait(1);
        return [{
            status: 'sent',
            peer_name: state.peer_name || '',
            item_title: state.item_title || '',
            price: state.price || '',
            location: state.location || '',
            message: text,
            peer_user_id: userId,
            item_id: itemId,
            url: url || '',
            item_url: state.item_url || '',
        }];

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Reload the conversation, wait for the composer to render, then retry
  2. Verify the URL points to an open Xianyu chat conversation
  3. Re-login to refresh a degraded session
  4. Update buildExtractChatStateEvaluate selectors if the chat DOM changed

Example fix

// before
await opencli xianyu reply --id 123 --text hi
// after: allow the page to settle first
await page.wait(5);
await opencli xianyu reply --id 123 --text hi
Defensive patterns

Strategy: validation

Validate before calling

const state = JSON.parse(await page.evaluate(buildExtractChatStateEvaluate()));
if (!state || state.requiresAuth) await xianyuLogin();
if (!state.can_input) throw new Error('Reply target input not ready — reload the conversation');

Type guard

function canInput(state) { return Boolean(state && state.can_input === true); }

Try / catch

try {
  await opencli xianyu reply --id 123 --text 'hi';
} catch (e) {
  if (e.code === 'SELECTOR' && e.message.includes('闲鱼聊天输入框')) {
    await page.reload(); await page.wait(5);
    await opencli xianyu reply --id 123 --text 'hi';
  } else throw e;
}

Prevention

When it happens

Trigger: Running the xianyu reply command (clis/xianyu/reply.js) on a conversation page whose extracted state reports can_input false, so buildSendMessageEvaluate never runs.

Common situations: Conversation page still rendering when state was read; session degraded so the composer is disabled; the reply target page redirected to a non-chat view; DOM changes broke the extractor.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/93a69f20652bdf88. Report an issue: GitHub.