- Here is a video tutorial
Creating Automated Tests with Gauge and Taiko: Logging into AWX
Welcome to this lesson, where we’ll walk you through utilizing Gauge and Taiko to create a basic automated test. This test will carry out basic tasks and automate the AWX administration interface login process. The main goal of this article is to automate a test that opens the AWX (Ansible AWX) login screen, inputs credentials, and then completes a basic activity, such cleaning tasks.
Using some functionalities from a Gauge example, we will begin by starting from scratch with a new spec file and associated JavaScript file.
Prerequisites
Ensure you have the following installed:
- Node.js
- Gauge
- Taiko
- Visual Studio Code or any preferred IDE
If you haven’t installed these yet, please refer back to the installation steps in my previous tutorials.
Step 1: Initialize a Gauge JavaScript Project
If you haven’t already set up a project:
- Create a new directory and navigate into it:
|
|
- Initialize a Gauge project with JavaScript:
|
|
This command sets up a basic project structure with example specs and support files.
Step 2: Explore the Example Files
Take a moment to examine the example spec and JavaScript files created by gauge init js
. These files provide a good starting point for understanding how to interact with web elements using Taiko.
Step 3: Create a New Spec File
- In your Gauge project directory, create a new file called
login.spec
. - Start by defining the spec title and a scenario:
|
|
Step 4: Implement the Spec in JavaScript
Create a new JavaScript file named login.js
and start scripting the actions:
- Import Taiko and necessary Gauge annotations:
|
|
- Implement the steps:
|
|
Step 5: Run Your Test from command line
Now that your spec and implementation are ready:
- Open your terminal.
- Run the test by executing:
|
|
Step 5: Run Your Test from Visual Studio Code
- Make sure your project structure is right and save all files.
- Start the test by entering ‘Gauge: Run All Specifications’ in the Command Palette ({Ctrl+Shift+P}). You can also click Run spec or scenario (accessible in Visual Studio Code after installing the Gauge extension) to run all of your specifications and view the results directly in Visual Studio Code.
Conclusion
This post demonstrated how to use Gauge and Taiko to develop a simple automated test for logging into AWX. More complex scenarios can be automated using this approach by modifying the JavaScript and spec files. Try out various functions and assignments as required.