You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Botium脚本内存变量存储与响应匹配报错问题求助

Solutions to Your Botium Testing Issues

Let's work through your two Botium problems step by step—these are common pitfalls, so I’ve got some concrete fixes for you:

1. Fixing Variable Capture Failure (TranscriptError)

You’re trying to capture the 99 value into $id but Botium isn’t matching your expected $id | This is a test pattern. Here’s what’s going wrong and how to fix it:

  • Correct the variable capture syntax: Botium uses {{$VARNAME=REGEX_PATTERN}} to define variable captures in expected responses, not just $VARNAME. Your expected line should look like this:

    #bot
    {{$id=\d+}} | This is a test
    

    The \d+ regex matches any numeric value (like 99), and Botium will store it in the $id variable for later use.

  • Verify memory is properly enabled: While you set export BOTIUM_ENABLE_MEMORY=true, Botium prioritizes config file settings over environment variables. Double-check your botium.json has:

    "SCRIPTING_ENABLE_MEMORY": true
    

    This ensures script-level memory variables are active.

  • Confirm environment variable scope: If you ran export in one terminal then opened a new one to run sudo botium-cli run mochawesome, the environment variable won’t carry over. Either re-run the export command in the same terminal, or add the setting directly to botium.json for reliability.

  • Update Botium CLI: Outdated versions sometimes have memory variable bugs. Run this to get the latest:

    sudo npm install -g botium-cli
    

2. Fixing Regex SyntaxError for Special Character Responses

Your bot’s response includes asterisks and newlines, which are breaking regex matching. Even after removing asterisks, you’re still hitting errors—here’s how to resolve this:

  • Escape special regex characters: If you’re using the default regex matching mode, characters like *, ., and newlines need to be escaped. For your original response, the expected line should look like this (note the escaped \* and \n):

    #bot
    {{/^\*Hier sind deine Erinnerungen:\*\n\nKeine Notizen, oder alles erledigt\.$/}}
    

    The {{/ /}} wrapper tells Botium this is a regex pattern.

  • Try wildcard matching instead: If regex feels too cumbersome, switch to wildcard mode in botium.json:

    "SCRIPTING_MATCHING_MODE": "wildcard"
    

    In wildcard mode, * acts as a placeholder, so to match the actual asterisks in your response, escape them with \:

    #bot
    \*Hier sind deine Erinnerungen:\*\n\nKeine Notizen, oder alles erledigt.
    
  • Check what Botium actually receives: Use the verbose log to confirm the exact response Botium is getting. Sometimes there are hidden spaces, extra newlines, or the response is a full JSON object (not just the fulfillmentText content). If it’s the full JSON, adjust your expected response to match the entire structure, or configure your Botium connector to extract just the fulfillmentText value.

  • Avoid raw JSON in expectations: If your connector is already extracting the fulfillmentText (most do by default), don’t include the surrounding {'fulfillmentText': '...'} in your expected line—just use the text inside the quotes.

内容的提问来源于stack exchange,提问作者ToWy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 08:46:30