botium-bindings icon indicating copy to clipboard operation
botium-bindings copied to clipboard

How to test if Bot is showing dynamic data

Open stephenws opened this issue 6 years ago • 6 comments

Hello All

My Testing Bot is showing dynamic data Suppose, I asked to Bot : What is Emp id of Stephen Then he will Reply : 12214

Like wise for Dynamic data how can we test

stephenws avatar Oct 18 '18 10:10 stephenws

Two options:

  1. You can use regular expressions, for this you can configure the matching mode capability (https://github.com/codeforequity-at/botium-core/wiki/Botium-Configuration#scripting_matching_mode)

  2. Dependening on your scenario, you can use seperate utterances files as well - if you would allow one of several bot responses (https://github.com/codeforequity-at/botium-core/wiki/Botium-Scripting#composing-in-text-files)

codeforequity-at avatar Oct 18 '18 10:10 codeforequity-at

I found this documentation page https://botium.atlassian.net/wiki/spaces/BOTIUM/pages/60817419/What+are+the+Advanced+Scripting+Settings+in+Botium+Box , but the regular expressions are still not working for me in botium-bindings.

my config

{
  "botium": {
    "Capabilities": {
      "PROJECTNAME": "Kelle Chatbot",
      "CONTAINERMODE": "simplerest",
      "WAITFORBOTTIMEOUT": "10000",
      "SCRIPTING_ENABLE_MEMORY": "true", // i think this is vital?
      "SIMPLEREST_METHOD": "POST",
      "SIMPLEREST_URL": "http://localhost:3000/webhook",
      "SIMPLEREST_HEADERS_TEMPLATE": {
        "Content-Type": "application/json"
      },
      "SIMPLEREST_REQUEST_HOOK": "./botium/modules/requestHook.js",
      "SIMPLEREST_BODY_TEMPLATE": {
        "plainText": true,
        "userId": "b6742761-f00b-4ca3-96c9-07b6e044d903",
        "message": "{{msg.messageText}}"
      },
      "SIMPLEREST_PING_URL": "http://localhost:3000/ping",
      "SIMPLEREST_RESPONSE_JSONPATH": "$.payload.facebook.text",
      "SIMPLEREST_RESPONSE_HOOK": "botMsg.cards = context.payload.attachments && context.payload.attachments.adaptiveCards",
      "SIMPLEREST_CONTEXT_JSONPATH": "$",
      "SIMPLEREST_MEDIA_JSONPATH": "$.payload.attachments.adaptiveCards[*].body[*].columns[*].items[1].text",
      "ASSERTERS": [
        {
          "ref": "CARDS",
          "src": "./botium/asserters/CardAsserter.js"
        },
        {
          "ref": "LOCATION",
          "src": "./botium/asserters/LocationAsserter.js"
        },
        {
          "ref": "POLYGON",
          "src": "./botium/asserters/PolygonAsserter.js"
        }
      ]
    },
    "Sources": {},
    "Envs": {}
  }
}

test convo

Profit Share this year

#me
profit share 2019

#bot
Your total profit share for 2019 from [January|February|March|April] to [October|November|December] totals $655.72.
CARDS profitshare

error


    TranscriptError: BotiumError: Profit Share this year/Line 6: Expected bot response (on Line 3: #me - profit share 2019) "Your total profit share for 2019 from January to October totals $655.72." to match one of "Your total profit share for 2019 from [January|February|March|April] to [October|November|December] totals $655.72."

It seems that whatever I type it's always escaped...

piotrjak avatar Oct 03 '19 14:10 piotrjak

SCRIPTING_ENABLE_MEMORY is not vital for this example. SCRIPTING_MATCHING_MODE capability is missing, you have to tell Botium to interpret the assertions as regular expressions. Finally, the $ character and the . characters have to be escaped to use it as literal in a regular expression:

#bot
Your total profit share for 2019 from [January|February|March|April] to [October|November|December] totals \$655\.72\.

codeforequity-at avatar Oct 03 '19 14:10 codeforequity-at

thanks for the response, but unfortunately it still doesn't work botum.json

      "SCRIPTING_MATCHING_MODE": "regexpIgnoreCase", // regexp doesn't work either

error

   TranscriptError: BotiumError: Profit Share this year/Line 6: Expected bot response (on Line 3: #me - profit share 2019) "Your total profit share for 2019 from January to October totals $655.72." to match one of "Your total profit share for 2019 from [January|February|March|April] to [October|November|December] totals \$655\.72\."

starting botium bindings

bb.helper.jest().setupJestTestSuite();

piotrjak avatar Oct 04 '19 10:10 piotrjak

ok, it works for "regexp", but not for "regexpIgnoreCase" when I actually provide the right regex

January|February

and not

[January|February]

piotrjak avatar Oct 04 '19 11:10 piotrjak

the mode regexpIgnoreCase is only included in the very very latest botium-core build. maybe you have to update the software first.

codeforequity-at avatar Oct 04 '19 17:10 codeforequity-at