Best practices for recording tests on Low Code Automation
This guide provides a brief overview of best practices for recording tests.
Low Code Automation provides an easy-to-use recorder for quickly automating tests. To create robust, reliable, and scalable tests from the start, it’s essential to follow recommended guidelines. These help prevent common pitfalls and inefficiencies, ensuring your tests are effective and easy to maintain.
Ensure website testability while recording and replaying tests
Website testability refers to the ease with which a website can be tested for defects, performance, and usability. When automating websites protected by reCAPTCHA, Cloudflare MFA, and similar security measures, it’s essential to follow best practices to ensure smooth automation and accurate test results. This section explains how to configure an application under test to achieve consistent and reliable outcomes without interruptions.
-
Meaningful Element Attributes: Websites that use meaningful and unique attributes for their elements enable more stable and reliable test execution. Examples of meaningful and unique attributes include descriptive IDs, unique class names, and data-* attributes that clearly define the purpose and context of each element. This practice reduces the likelihood of test failures due to website structure or design changes. The following are examples of a few meaningful attributes:
data-test = "submit-button"
data-testid = "search-input-field"
data-test-id = "forgot-password-link"
data-cy = "product-menu-dropdown"
data-qa = "terms-and-conditions-checkbox"
id = "creditcard-number-input"
title = "Sign In Button"
placeholder = "Enter your email address"
alt = "User profile picture"
label = "Email Address"
Low Code Automation also features a robust element selection algorithm that ensures unique element identification, even if attributes change over time. This algorithm incorporates AI self-healing, which considers page context to accurately locate elements.
-
Localization: Websites implementing localization load different content in various countries or regions.
Examples include websites like:
- Amazon: Adjusting prices, currency, and product availability based on the user’s location.
- Google: Offering search results and interface in local languages and customizing search algorithms to prioritize local content.
You can manage this in the following ways:
- Record tests using country/region-specific URLs (e.g., amazon.in, amazon.co.uk).
- Set the appropriate geographic region/country before starting tests, if supported by the website.
- Utilize the Custom Actions(JavaScript) step for localization.
- You can also set IP Geolocation to test your website from different geolocations. Learn more on IP Geolocation, language & locale.
-
A/B testing: A/B testing is a method used to compare two versions of a webpage or app to determine which one performs better. To ensure the same version of the page is loaded consistently during test execution, use the following methods:
- Disable A/B testing on staging if feasible.
- Use Advanced test configurations to set cookies or local storage to store the assigned version for each user.
Learn more on Advanced test configurations.
-
Cloudflare: Cloudflare enhance website security and performance through advanced bot protection and content delivery optimization. If you have enabled these services for your site’s security and performance, consider deactivating them in the testing environment to allow low-code automation to execute actions. If disabling them is not feasible, you can configure exceptions in Cloudflare and other firewalls. Use the following header-value pair provided by the Low Code Automation Application.
-
X-Test-Executor: bstack-lca
This pair can be included as part of all local and cloud executions. Alternatively, configure a cookie or headers in Advanced test configurations and enable them through custom rules in your web application firewall (WAF).
-
-
ReCaptcha: ReCaptcha is a security service by Google that helps protect websites from spam and abuse by distinguishing between human users and bots through various challenges. Consider deactivating them in the testing environment to allow low-code automation to execute actions as they hinder automated scripts and bots from performing actions.
- Multi-Factor Authentication (MFA): Multi-Factor Authentication is a security process that requires providing two or more verification factors to gain access to a system or application. It adds an extra layer of security by requiring multiple forms of verification before granting access. In staging environments, it’s advisable to disable MFA or use static codes for verification since the goal of testing is not to assess the MFA service, which is likely provided by an external service.
How to use validations effectively
Validations in Low Code Automation covers three essential validation methods, visual validation, text validation, and element presence validation. These methods help ensure the accuracy and reliability of your automated tests without extensive coding. Effective validation techniques include validations at various checkpoints, element presence validation, dynamic content and individual element validations.
-
Add validations at different checkpoints: Utilize validations at various checkpoints when the page context changes. For example:
- On page load with a modal popup: Ensure that the modal popup appears correctly upon page load. Validate elements within the modal such as text, buttons, and links to confirm they are displayed and functional. This helps to verify that the initial user interaction is as expected.
- After successful login: Validate the page content and elements after a user logs in successfully. Check that the login credentials have been processed correctly and that the user is redirected to the appropriate landing page. Confirm the presence of user-specific elements such as profile information, personalized messages, or user-specific navigation options.
- When navigating to the checkout page: Validate the transition and elements when a user navigates to the checkout page. Ensure that all items in the cart are displayed correctly, along with accurate pricing and total amounts. Verify that all necessary fields for completing a purchase (e.g., shipping information, payment options) are present and functional.
- Following payment completion: Validate the confirmation page or message that appears after a successful payment. Check for the presence of order details, payment confirmation, and any next steps or actions (e.g., tracking the shipment, viewing order history). This step ensures that the transaction process has completed correctly and that the user receives appropriate feedback.
- Dynamic content: Avoid adding visual validations on dynamic content like news articles or advertisements.
- Individual element validations: Validate individual elements of interest instead of the full page.
- Element presence validation: When the page contains pop-ups at irregular intervals, consider adding an element presence validation before interacting with them.
Learn more on Adding Validations.
Review tests before saving
- Remove redundant steps: The recorder captures every action performed on the website. If any actions were performed unintentionally and do not need to be part of the test, ensure you delete them to avoid issues during execution.
- Single logical flow: Record tests with single logical flow to reduce error-prone scenarios.
- Dynamic inputs: Convert steps requiring random or dynamic values into functions. For example, when recording a test for a new user registration flow, ensure that a new email is generated each time. Learn more.
- Reuse common steps: Convert steps that could be used across multiple tests into modules for easier reuse. Learn more.
- Variable usage: Convert static data in your tests to variables. This makes test maintenance easier. If a value needs to be updated at multiple steps, you can simply update the variable value once, and it will apply across the test. Learn more.
- Auto Execute: Use auto execute during editing tests to ensure the browser is in the correct state.
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
We're sorry to hear that. Please share your feedback so we can do better
Contact our Support team for immediate help while we work on improving our docs.
We're continuously improving our docs. We'd love to know what you liked
Thank you for your valuable feedback!