Taiko – A Free and Open Source Browser Automation Tool

Taiko the automation tool

Taiko – A Free and Open Source Browser Automation Tool

Taiko is an automation tool which is freely available and it is an open source browser automation tool. It is built by ThoughtWorks team. It uses Node.js library to automate the chrome browser. Taiko is very useful to create maintainable and highly readable JavaScript tests. 

Taiko has a simple API, smart selectors and implicit waits. All these work together towards a single goal – No more flaky tests.

Taiko the automation toolFeatures

Taiko is built ground up to test modern web applications. Below is a list of some of taiko’s features that differ from other browser automation tools.

  • Easy Installation
  • Interactive Recorder
  • Smart Selectors
  • Handle XHR and dynamic content
  • Request/Response stubbing and mocking

Getting Started:

Easy Installation

We can use Taiko on three platform:

1. Windows
2. MacOS
3. Linux

Before start work on Taiko scripts in JavaScript, Node.js should be installed in your system. After that open a command prompt (For Windows) and install Taiko using below command:

$ npm install -g taiko


This will install Taiko and the Chromium browser with the latest version.

Taiko tool comes with a REPL Recorder which is used for writing test scripts. To launch the REPL, just type in CMD : 

$ taiko

Here is the output:

Version: 0.8.0 (Chromium:76.0.3803.0)

Type .api for help and .exit to quit
>

This will open the Taiko prompt in your cmd application. Now you can use Taiko’s API.

Let’s perform some tasks: 

Taiko’s REPL keeps a history of all ran commands. Once execution is finished, you can generate a test script using the below command : 

> .code

You can copy and modify the javascript code or save it to a file in your system using below command : 

> .code taiko_demo.js

As you can see the file is saved in the system.

file is saved in the system

You can finish the recording using the command shown below :

> .exit

If you want to run a Taiko script, for that you need to pass the file as an argument to Taiko

Run a Taiko script

By default Taiko runs the script in headless mode, this makes it easy to run Taiko.
To view the browser while executing the script, run command : 

$ taiko googlesearch.js –observe

There are some other methods of taiko that we can use to perform other tasks of taiko. To check all available API’s, run the command :
> .api

For more details of an API with examples use:

>.api openBrowser

Example:

    openBrowser()

    openBrowser({ headless: false })

    openBrowser({args:[‘–window-size=1440,900’]})

 

To know more about Taiko, please navigate to this link: https://taiko.gauge.org

Share this post