codeforequity-at / botium-core

The Selenium for Chatbots - Bots Testing Bots
https://www.botium.ai
MIT License
229 stars 64 forks source link

Checking whether the image url is accessible using the hyperlink asserter #281

Closed Aishwarya-J-S closed 5 years ago

Aishwarya-J-S commented 5 years ago

I have an image url in the start of my conversation with html tag (
Ok, let's make sure that ......). How to check if this (http://hostname:port/xxxx.gif) is reachable above the text through hyperlink asserter.

Chatbot hyperlink Asserter is also added in the Registered components

I have tried the following in the convo file

bot default

MEDIA http://hostname:port/xxx.gif HYPERLINK_ASSERTER 200
Ok, let's make sure that ...........

But got the below assertion error

Error: XXXXXX/Line 30: assertion error - Error: Line 30: Expected media with uri "http://hostname:port/xxxx.gif" at MediaAsserter.assertConvoStep (/app/agent/node_modules/botium-core/src/scripting/logichook/asserter/MediaAsserter.js:20:59) at p (/app/agent/node_modules/botium-core/src/scripting/ScriptingProvider.js:113:61) at Promise (/app/agent/node_modules/botium-core/src/scripting/ScriptingProvider.js:17:13) at new Promise () at p (/app/agent/node_modules/botium-core/src/scripting/ScriptingProvider.js:15:19) at asserters.filter.map.a (/app/agent/node_modules/botium-core/src/scripting/ScriptingProvider.js:113:17) at Array.map () at ScriptingProvider._createAsserterPromises (/app/agent/node_modules/botium-core/src/scripting/ScriptingProvider.js:113:8) at ScriptingProvider.assertConvoStep (/app/agent/node_modules/botium-core/src/scripting/ScriptingProvider.js:63:21) at scriptingEvents.onBotStart.then.then (/app/agent/node_modules/botium-core/src/scripting/Convo.js:338:36) at processTicksAndRejections (internal/process/task_queues.js:86:5)

codeforequity-at commented 5 years ago

The MEDIA asserter checks for the existance of a media attachment to the bot response (see here). It doesn't assert the actual availability of the media attachment url.

The Hyperlink asserter, which actually asserts the availability of the media attachment is part of the Enterprise plan (see here)

Aishwarya-J-S commented 5 years ago

I am currently using the Enterprise plan only.

Will not the hyperlink asserter check whether the url provided in the bot response is accessible by the following command?

MEDIA http://hostname:port/xxx.gif HYPERLINK_ASSERTER 200

Or how to check this feature if the url is concatenated along with the text in the bot response?

codeforequity-at commented 5 years ago

The MEDIA asserter will verify if the bot attached some media file to the response - it is just comparing URLs, nothing else - so if your bot response doesn't include an attachment named http://hostname:port/xxx.gif, then this asserter will fail - and that's what the error message actually tells: Expected media with uri "http://hostname:port/xxxx.gif"

When you are using Botium Box Enterprise, the Hyperlink Asserter (named CHECKLINK, not HYPERLINK_ASSERTER) is activated by default, so all links found in the bot response, wether embedded in text or as media attachment or as button url or what else, all of them will be checked.

Aishwarya-J-S commented 5 years ago

If the hyper link asserter is activated by default, if we have provided any url in the convo file then will it check whether the url is accessible by default and fail the test case if the url is not accessible

codeforequity-at commented 5 years ago

The hyperlink asserter will try to follow all hyperlinks detected in the bot response, and fail the test case if the url is not accessible. (what's asserted in the convo file is not part of the hyperlink asserter)

vijaysimh commented 5 years ago

Hi we need to verify URL for 404 status / and by clicking Url verify it lands to expected page .As am not using enterprise /commercial edition a normal basic botium version. How to verify the URL status.

ujja commented 5 years ago

Answer is here:

https://github.com/codeforequity-at/botium-asserter-basiclink

or here

https://stackoverflow.com/questions/56222058/how-can-i-use-hyperlink-assertion-using-botium-asserter-for-chatbot-developed-us

vijaysimh commented 5 years ago

Hello thanks for the suggestion as executing the above npm command : C:\Users\Vijay>npm install --save botium-asserter-basiclink

Facing this Error.Please help how to resolve this error

**npm ERR! Cannot read property 'match' of undefined

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Vijay\AppData\Roaming\npm-cache_logs\2019-05-30T14_21_51_081Z-debug.log**

ujja commented 5 years ago

It is NPM related.

See here https://npm.community/t/cannot-read-property-match-of-undefined/203 Or try using yarn please.