botium-bindings
botium-bindings copied to clipboard
How to test if Bot is showing dynamic data
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
Two options:
-
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)
-
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)
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...
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\.
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();
ok, it works for "regexp", but not for "regexpIgnoreCase" when I actually provide the right regex
January|February
and not
[January|February]
the mode regexpIgnoreCase is only included in the very very latest botium-core build. maybe you have to update the software first.