NashTech Insights

Taiko – An Introduction

Codeless and low-code automation frameworks are becoming increasingly popular nowadays, as they allow both automation testers and manual testers to quickly implement automation. In this article, I will introduce a low-code automation library – Taiko.

Table of Contents

I. Taiko Introduction

Taiko is free and open source Node.js library with a simple API to automate Chromium based browsers (Chrome, Microsoft Edge, Opera) and Firefox. It is built by the ThoughtWorks team.

Taiko is a great tool for writing readable and maintainable JavaScript tests.

II. Advantages of Taiko

  • Open Source: Taiko is licensed under the MIT License. All their features are free for commercial use.

  • Easy to learn and use:

Taiko’s API is designed to be simple and intuitive. This makes it easy for anyone to learn how to use the tool, even if they don’t have a lot of experience with coding.

  • Smart Locators:

Taiko’s API makes it easy for testers to select elements on the page by providing Smart Locators. Smart Locators allow you to select elements based on their text, appearance, or location, without having to know the underlying structure of the page.

For example, to click on the “Google Search” button, we can use the following code: click(“Google Search”)

  • Readable Test Scripts: 

Taiko’s API also mimics the way that users interact with a browser. For example, if you want to write text into an element, you can use the Taiko write API. This makes test scripts more readable and understandable for anyone, regardless of their technical expertise.

For example, the following code snippet shows how to write a text into a textbox:

  • Built-in wait mechanism:

    Taiko eliminates flakiness in UI automated tests by implicitly waiting for elements to be ready and events to be triggered, and by providing better custom wait mechanisms for users. This helps ensure that tests are only executed when the page is in the correct state, which prevents flakiness and reduces execution time

  • Interactive Recorder:

Taiko has an interactive REPL (read-eval-print loop) to record tests and generate clean JavaScript code.

Taiko’s REPL allows users to give instructions in the terminal, which are then performed on the browser. The user can continue to give instructions until they have completed a workflow. Only the successful actions are recorded as a script.

  • Emulate Network:

Offline support is essential for certain types of applications. For example, if you want a red banner to show up when an application is accessed in offline mode to prevent users from purchasing a product, this feature relies on the offline status. This can be tested by turning off the network or using Chrome DevTools to emulate offline mode. Taiko can also be used to do the same by using emulateNetwork API.

For example:

Taiko supports the following network modes: GPRS, Regular 2G, Good 2G, Good 3G, Regular 3G, Regular 4G, DSL, WiFi, and Offline.

  • Emulate Devices:

Taiko does not support testing mobile applications directly. However, it can be used to emulate the screen of mobile devices, which can be helpful for responsive testing.

For example, we can simulate the screen of an iPhone 6 by using the emulateDevice API.

  • Geolocation Test:

If you have an application with global users and have a map to show where the user is, you can use Taiko to test this setup by using setLocation API

First, we need to set permission to use geolocation for the specific website (in this case, it is google map):

Then we call the setLocation API with lat, long and accuracy:

  • Other features:

– Support proximity (relative) selectors.

– Support custom plugin. And we can create our own plugin for Taiko.

– Capture screenshot or record video on failed test scenario.

– Have Api to support testing Upload / Download file.

– Support for piercing through shadow DOM

– Taiko can integrate with different Test Framework such as: Gauge, Mocha or Jest

III. Disadvantages of Taiko

  • Taiko does not support Webkit based browsers like Safari.
  • Taiko does not support testing mobile applications. 
  • Taiko does not support API testing.
  • Currently, Taiko only supports JavaScript and TypeScript.
  • If you encounter any issues with Taiko’s API, you will need to contact the ThoughtWorks team for support.

III. Compare Taiko with other automation frameworks

V. Conclusion

I believe that Taiko is a great tool for manual testers with limited coding knowledge who want to get started with automation testing.

Additionally, Taiko is a good choice for projects that require easy-to-learn, flexible, and scalable automation tests. Besides, Taiko can be integrated with various JavaScript test frameworks, such as Gauge, Mocha, or Jest, to make it easier to maintain and extend.

In conclusion, I hope this article has helped you to better understand Taiko and its potential benefits for your project. If you are considering using automation testing, I encourage you to give Taiko a try.

References: -> Official Website -> Documentation -> Taiko Source Code

%d bloggers like this: