Can we add Javascript hook after connecting to chat in

Hello Florian,

I am using “E2E UI/UX Testing” connector with automation technology “Selenium”. In my project we have condition to perform some action on input data after connecting to bot. Can we add Javascript Hook and perform task in between after connecting to chat bot.

Regards,
Deepak Kumar

More details please. There are several Javascript hooks already available, but from your description I cannot tell if your case is covered.

When we successfully connect to chatbot and able to start conversation. In between of conversation we have a situation of changing an option say mobile number, for that we need to select one element from chatbot and open a dialog box which needs to be handled. This dialog box have a text area and submit button that need to handle as well. For all this we are looking for javascript hook to handle element after chatbot connection.

This should be doable with a Logic Hook - docs in the Botium Wiki.

The logic hook should implement the logic of

  • getting access to the current Connector handle (container.pluginInstance)
  • doing the things like clicking button and making selection

In the BotiumScript it will look like this:

LH_SELECT_MOBILE_NUMBER 056346444

In the botium.json, it will look like this:

{
  "botium": {
    "Capabilities": {
      ...
      "LOGIC_HOOKS": [
        {
          "ref": "LH_SELECT_MOBILE_NUMBER",
          "src": "src/lh_select_mobile_number.js"
        }
      ]
    }
  }
}

And the file src/lh_select_mobile_number.js will look something like:

module.exports = class MyCustomLogicHook {
  constructor (context, caps, globalArgs) {
    this.context = context
    this.caps = caps
    this.globalArgs = globalArgs
  }

  onMeStart ({ container, args }) {
   container.pluginInstance._runInQueue(async () => {
      //this is the WebdriverIO browser instance if needed
      const browser = container.pluginInstance.browser
     
      const myBtn = await this.findElement('.my-button')
      await myBtn.click()
      // and here some more WebdriverIO code ...
    })
  }
}

The _runInQueue is needed to not interfere with other Selenium calls that might happen the same time, like checking for chatbot response