writing plugins

Taiko features can be extended via plugins which can allow users to take more advantage of ChromeDevtoolsProtocol when core Taiko concentrating on functionalities around UI automation tests. It can also help users simplify their workflow. Below are a few scenarios where plugins can help extending taiko:


module.exports = {
    'exec': (options) => {
        console.log("Taiko's plugin executes operation with following options");
capability:[‘subcommands’]` - in plugins package.json 

Only if the package.json has the above capability added taiko will consider it to be a subcommand.

Initializing plugin

Plugins are initialized by calling init method defined in plugins. Below are the parameters that init method takes, init(taiko, eventHandlerProxy, descEvent, registerHooks)

Hooks for plugin

Taiko provides a way for plugins to alter its behavior by letting them register hooks. Below are the available hooks in taiko,

//Hooks example
init(taiko, eventHandlerProxy, descEvent, registerHooks){
            preConnectionHook: (target, options) => {
                  return {target,options}

Plugin Workflow

Taiko plugin workflow


const { openBrowser, goto, write, press, closeBrowser, into, screencast} = require('taiko');

(async () => {
  try {
        await openBrowser();
        await screencast.startScreencast("output.gif");
        await goto('google.com');
        await write('taiko', into(textBox()));
        await press('Enter');
  } catch (e) {
  } finally {
        await screencast.stopScreencast();
        await closeBrowser();

Running scripts with plugins

Execution capability in plugin

Example: taiko diagnostics http://gauge.org