Taiko - Installation And Start Writing Your Test Scripts...
Writing your first Taiko script is a simple process, as Taiko is designed to have a user-friendly and straightforward API. Here's a step-by-step guide to writing your first Taiko script:
Prerequisites:
Ensure you have Node.js installed on your system. You can download it from the official website: https://nodejs.org/
Advisable is to download the LTS version as it would be more stable
Click on the downloaded Window Installer Package
We will get the below screen and click on Next Button> Accept the End User License Agreement and click on Next > Click on Next >Click on Next>Click on Next>Click Install
Select Yes and it will take some secs to install > click Finish
Check that node is install on your system , we can check on cmd as below
Quick Installation:
If you want to experiment or quickly automate a web page you can get started with Taiko using Node's npx package runner.
Type below command in cmd
This will download chromium browser and launch Taiko's recorder.
To see what all APIs are available in Taiko , Type below command and it will display the API references.
Here, with the help of API reference you can start with Baby Step, Bingo we open browser > navigated to google > clicked on "I'm Feeling Lucky" button and navigated to doodles page.
This is just a start, we have to learn lot more
Taiko’s REPL keeps a history of all successful commands. Once you finish an execution flow, generate a test script using the special command .code
Now , You can save this script in .js file (All taiko scripts should be saved with .js extension)
Type .code
You can save the code in .js file as below
领英推荐
Check the saved file in users folder
We can run the same google.js from cmd and it will perform the same actions as we did above.
First get out the existing session by .exit
and Type Below command to run google.js script
Taiko Runs in headless mode , we will see in our next article how to run in headful mode or in visible browser.
Global Installation #
If prefer having the taiko command installed globally, you can run below command on cmd. We need to wait for sometime for the download and can check the version as below
Local installation #
As any other Node.js library Taiko, you can add Taiko to your node projects by running
npm install -D taiko
This will add Taiko as a dev dependency in your project's package.json
You can also run
npx taiko
To launch the Taiko recorder locally. This will refer to the local installation of Taiko in the node_modules folder.
Install options #
You can skip downloading chromium while running or install Taiko by setting the environment variable TAIKO_SKIP_CHROMIUM_DOWNLOAD to true for example in bash or zsh
TAIKO_SKIP_CHROMIUM_DOWNLOAD=true npx taiko
Each Operating System has it's own way of setting environment variables please refer OS specific instructions on how to do that.
Feel free to drop your thoughts and suggestions in the comments, and don’t hesitate to share them with your friends.
Let’s embark on this learning adventure together, grow our skills, and share our knowledge!
Happy Testing ??????