Maximizing the Potential of Low-Code Test Automation with Ghost Inspector
Low-code tools are among the options available for automating tests. One particular tool we utilize for automating browser tests is Ghost Inspector, which falls into the low-code category. By using Ghost Inspector, you can develop dependable automated tests and gain valuable insights into test automation.
Ghost Inspector allows test automation without the need for coding. Instead, tests can be constructed using non-coding steps. By employing identifiers such as XPath or CSS selectors, you can pinpoint elements on the web page being tested. Afterwards, you can select a test step that interacts with the element in the desired manner, such as clicking or assigning a value. This approach simplifies the creation of automated tests. Creating tests without code is beneficial for testers who lack coding skills, enabling them to start creating tests. However, if a significant number of tests are created in this manner, they can become challenging to maintain and comprehend. Maintenance can be time-consuming since any changes to the tested page’s elements require finding and updating each instance of the element. Moreover, tests created without code can be difficult to understand, as they involve steps like clicking on a div with a specific class prefix, followed by waiting for a span with a certain class content. This complexity leaves readers struggling to decipher the purpose of these steps.
To optimize the utilization of low-code tools and enhance the maintainability and readability of tests, several approaches can be implemented.
Maintaining your tests:
To enhance the readability and maintainability of tests, one effective approach is to group steps together within a module that can be imported into tests. By encapsulating steps in a module, the process of maintaining tests becomes more convenient. When a page element undergoes changes, you only need to update the steps within the module, rather than modifying steps across multiple tests. This simplifies and expedites the maintenance process. Additionally, creating new tests becomes faster when modules are available. Instead of crafting new steps for each new test, you can leverage existing modules to build the tests. For instance, you can import a “login” module containing login steps, eliminating the need to recreate all the login steps for each test. Whenever a test requires login functionality, the login module can be utilized.
The naming of these modules holds significance for two reasons. Firstly, it is crucial to assign a name that is easily identifiable within your library of modules. Secondly, the name should be descriptive, allowing a clear understanding of the module’s purpose when encountered in a test. Well-named modules greatly contribute to the readability of your tests.
Dynamic behavior with Variables:
Ghost Inspector is a low-code tool that offers support for utilizing variables. While it’s possible to create tests without variables, incorporating variables into your tests also enhances their creation, maintenance, and readability. Variables serve as containers for holding values that can be updated. These values can encompass URLs, emails, passwords, CSS selectors, or any other data required by a test. If the value represented by a variable changes, you only need to modify the value stored in the variable itself, instead of updating it everywhere it is used. Ensuring that your variables have easily understandable names contributes to the clarity of your tests.
Variables operate within a specific scope, which can be a single test, a test suite, or the ‘global’ scope, enabling the variable to be utilized across all tests and test suites. Variables created within a test are limited to that specific test, while variables created within a test suite are applicable only to tests within that suite. On the other hand, variables created at the organization level have a global impact and can be accessed by all tests created within it.
Modules have the ability to make use of the variables you create. For instance, a module could assign values to variables for email and password, allowing the login module to utilize those variables for logging in. This approach enables the login module to be used for logging in as different users, based on the values stored in the variables.
JavaScript for Dynamic Behavior:
Ghost Inspector offers the capability to utilize JavaScript for creating steps within tests. By incorporating JavaScript, you can generate steps that execute JavaScript code, where the code either returns true or extracts a variable. While it’s not mandatory to use JavaScript in Ghost Inspector tests, leveraging JavaScript within test steps allows you to extend the functionality of Ghost Inspector and serves as a means to learn JavaScript at your own pace. Numerous resources are available for learning JavaScript, providing ample opportunities to enhance your understanding. One approach is to store variables in a JavaScript object using an “Extract From JavaScript Object” step, as demonstrated below:
const emailAndPassword = { email: “user@email.com”, password: “password” };
return emailAndPassword;
Subsequently, you can utilize the variable within a module to log in to the application being tested. Furthermore, you can create steps that extract values from page elements or generate a variable based on values stored within a JavaScript object. Ghost Inspector includes a step that checks for the presence of an element on a page. If you need to check for multiple elements with the same CSS selector, you can create a step using document.querySelectorAll(selector).length to obtain the number of elements, and then employ an ‘if loop’ to verify if the number of elements is correct. If the expected number of elements is found, the step will return true; otherwise, it will return false, indicating test failure. Developing steps using JavaScript can assist in honing your JavaScript skills at your own pace.
Establishing standards for your tests can contribute to consistency and facilitate maintenance. For instance, you can implement a naming standard for variables. An example of such a standard would entail using a prefix to denote the variable’s scope, whether it is local to a test, a test suite, or a global variable applicable across all tests. A naming standard for variables could adhere to the following guidelines:
- Names should be in camel case.
- Organization-level variables should begin with “org.”
- Test suite-level variables should begin with “ts.”
By adhering to this standard, you can enhance the management and development of your tests since the scope of a variable can be determined by simply examining its name. These standards can be expanded to include other useful points, such as preferred element selectors or guidelines for organizing libraries of modules. Utilizing standards when creating tests also fosters collaboration, as all test creators can adhere to the established guidelines.
Apply the Five S’s(methodology):
In order to establish a structured and disciplined approach for creating and maintaining automated low-code tests, utilizing the Five S’s proves to be highly beneficial. Mary and Tom Poppendiek recommend the Five S’s as a means of instilling the necessary discipline for developing quality software. They describe these principles as a classic lean tool for organizing workspaces [1]. By implementing the Five S’s, Ghost Inspector automated tests can be effectively maintained, ensuring they are easy to manage, free from flaky behavior, and exhibit readability.
The Five S’s are extensively explained in “Implementing Lean Software Development” [1], where the original Japanese terms are translated into English and practical examples are provided for their application in development projects. Drawing inspiration from Mary and Tom Poppendiek’s concept, I have created a table presenting the English translations of the Japanese words, along with examples demonstrating the utilization of the Five S’s in the Ghost Inspector test automation.
Step Name(English) | Japanese term | Ghost Inspector Test Automation | |
1 | Sort | Seiri (tidiness) | Remove unused modules |
2 | Set In Order | Seiton (orderliness) | Organize test, test suites and modules So, that everything is easy to find |
3 | Shine | Seiso (cleanliness) | Bring old tests in line with the standards and improve performance. |
4 | Standardize | Seiketsu (standardization) | Create Standards, Reduce complexity and improve ease of maintenance. |
5 | Sustain | Shitsuke (discipline) | Use and follow standard procedures. |
Among the Five S’s, Sustain holds significant importance, as it serves as a cornerstone for ensuring the longevity of the practices established through the Five S’s. By sustaining these practices, your automated tests will become more reliable, easier to maintain, and simpler to comprehend.
Conclusion:
By implementing these strategies, you can maximize the potential of low-code test automation with Ghost Inspector. Your tests will become more maintainable, consistent, and readable, ultimately improving the efficiency and reliability of your test automation efforts. Additionally, you’ll gain valuable software development skills, such as variable scoping, JavaScript coding, module encapsulation, and adherence to standards. These skills will prove invaluable as you continue to enhance your test automation capabilities