Guidelines for using the AI Blocks

This article outlines suggestions and examples of using the AI block so that you can make the most out of the AI Blocks and ensure that the test data generated is appropriate for your automation needs. 

Writing effective prompts

Writing effective prompts is key to getting the most out of any AI system. Whether you're working with an AI to generate data, answer questions, or automate processes, your prompt should be clear, focused, and well-structured. Following these best practices will help you achieve accurate and relevant results:

  • Be Clear and Specific: A specific prompt improves the AI's understanding of the task.

    • Poor Prompt: "Generate a name."

    • Good Prompt: "Generate a common Spanish male name."

  • Provide Context When Necessary: Including context tailors the output to your requirements.

    • Poor Prompt: "Generate a phone number."

    • Good Prompt: "Generate a phone number for a user in California with a valid area code."

  • Use Simple and Direct Language: Avoid unnecessary complexity to minimize confusion.

    • Poor Prompt: "Could you kindly generate a fictitious email address for testing purposes?"

    • Good Prompt: "Generate a random email address."

  • Avoid Ambiguity: Providing precise instructions reduces the likelihood of unexpected outputs, particularly when specifying formats or ranges.

    • Poor Prompt: "Generate a date."

    • Good Prompt: "Generate a birthdate between 1990 and 2000 in the format DD/MM/YYYY"

  • Break Complex Requests Into Smaller Parts: Simplifying tasks improves accuracy. Avoid combining distinct tasks into one prompt. Instead, break them into sequential requests for better accuracy

    • Poor Prompt: "Generate a set of user profiles with name, email, and phone number, then link each profile to a country of origin based on the phone number."

    • Good Prompt: "Generate a random first name as the first step."

Overview of the AI Blocks

AI Blocks in Leapwork integrate advanced AI capabilities into testing workflows, automating tasks, improving efficiency, and enabling quick adaptation to changing needs.

The available blocks, AI Extract, Generate, Transform, and Validate, support diverse use cases, from creating test data to validating and transforming it. To activate these blocks, follow the steps in the Customer Portal.

Key Features:

Potential Use Cases:

  • Generates Structured Test Data: Quickly creates names, emails, addresses, and other sample data for automation testing.

  • Automated Testing: Create realistic data like user profiles or addresses to test web applications and APIs.

  • Input Validation: The block ensures all requests fit automation test data standards, blocking irrelevant or inappropriate requests.

  • Form and Validation Testing: Generate data to verify form fields, input validation, and error handling.

  • Error Handling: Provides clear error messages for invalid prompts or misuse.

  • E-Commerce: Test product listings, pricing, and other shopping-related data.

  • Single Record Generation: Currently supports generating one test data record at a time, with workarounds available for larger datasets.

  • Data Workflow Verification: Validate business workflows such as age or address checks.

Guidelines for Using the AI Generate Block

Please do note, while adding fields in the block, their label must match the values we are requesting in the prompt, otherwise the execution might not be successful or as desired.

 What You Can Do

  1. Generate simple test data such as names, emails, or addresses.

image-20260218-124501.png

Example: “Generate a test user with name and email.”

Output: “Generated Name: John Doe, Email: johndoe123@example.com (AI took 1,5 seconds)“

  1. Use automation-friendly requests like phone numbers or product data.

image-20260218-104249.png

Example: “Create a sample with valid phone numbers.”

Output: “Generated Phone_Number: +1-202-555-0173 (AI took 1,4 seconds) “

  1. Create data for testing e-commerce, forms, or validation workflows.

image-20260218-104557.png

Example: “Generate 3 sample product names for an online store.”

Output: “Generated Product_Name1: EcoSmart Water Bottle, Product_Name2: UltraSoft Bamboo Sheets, Product_Name3: SmartHome LED Bulb (AI took 4 seconds) “

  1. Create data for filling online form with 10 Indian male names.

image-20260218-104940.png

Example: "Generate 10 sample Indian male names for a form filling"

Output: "Generated Indian_Male_Name_1: Aarav Kumar, Indian_Male_Name_2: Vihaan Mehta, Indian_Male_Name_3: Sai Reddy, Indian_Male_Name_4: Arjun Patel, Indian_Male_Name_5: Rajesh Sharma, Indian_Male_Name_6: Karan Verma, Indian_Male_Name_7: Aayush Joshi, Indian_Male_Name_8: Rohan Gupta, Indian_Male_Name_9: Vikram Singh, Indian_Male_Name_10: Rakesh Rao (AI took 9.1 seconds)"

 What You Should Avoid

  1. Don’t request creative content, like stories or narratives.

image-20260218-105108.png

Example: “Write a story about a test engineer.”

Output: “The request is asking for a story, which falls outside the specified use cases for generating structured data for testing purposes. The request does not imply a need for structured data output suitable for test automation.”

  1. Avoid asking for sensitive information, such as passwords or credit card numbers.

image-20260218-124842.png


Example: “Generate a password for an account.”

Output: “The request does not imply a need for structured data generation for testing purposes as it asks for a single password generation, which does not specify multiple or single data fields or detailed specifications for structured data output.

  1. Don’t expect real-time data, like the current time or date.

image-20260218-124944.png


Example: “Generate today’s date.”

Output: “The request does not imply a need for structured data generation for testing purposes as it asks for a specific date rather than random structured data fields.”

Guidelines for Using the AI Validate Block

 What You Can Do

  1. Validate the purpose and type of information.

image-20260218-110034.png

Input:

def swap_numbers(a, b):
    return b, a
# Example usage
num1 = 5
num2 = 10
print(f"Before swapping: num1 = {num1}, num2 = {num2}")
num1, num2 = swap_numbers(num1, num2)
print(f"After swapping: num1 = {num1}, num2 = {num2}")


Expected: “Python code to swap 2 numbers “

Output: “The input matched the expected value (AI took 1.5 seconds) “

  1. Validate type of information or structured data.

image-20260218-110221.png

Input: “Card Number: 1234 5678 9012 3456, Expire Date: 12/26, CVV: 123”

Expected: “credit card information“

Output: “The input matched the expected value (AI took 1.7 seconds)“

  1. Check equivalence of two strings with similar purposes.

image-20260218-110758.png

Input: “To book a demo of our leapwork tool please contact our sales team sales@leapwork.com

Expected: “Contact leapwork support team on sales@leapwork.com to book a demo of the leapwork tool“

Output: “The input matched the expected value (AI took 1.3 seconds) “

What You Should Avoid

  1. Don’t validate empty fields or spaces.

image-20260218-111229.png

Input: (blank)

Expected: (blank)

Output: “The Actual field is required., The Expected field is required. “

  1. Avoid ambiguous or overly generalized benchmarks.

image-20260218-112035.png

Input: “Long Island is Colm Tóibín’s masterpiece: an exquisite, exhilarating novel that asks whether it is possible to truly return to the past and renew the great love that seemed gone forever. The sequel to the prize-winning, bestselling novel Brooklyn.“

Expected: “Details of the Book Long Island by Colm Tóibín“

Output: “The input result provides a description of a book but does not include specific details about the book 'Long Island' by Colm Tóibín, such as publication date, publisher, or plot summary. It also refers to it as a sequel to 'Brooklyn', which is not consistent with known works by Colm Tóibín. “

  1. Don’t rely on subjective or unclear conclusions.

image-20260218-112615.png


Input: “The stone total weight is 1000 grams “

Expected: “The stones are not heavy “

Output: “The input result indicates that the stones weigh 1000 grams, which contradicts the expected result stating that the stones are not heavy.“

Guidelines for Using the AI Extract Block

 What You Can Do

  1. Extract key details from structured text.

image-20260218-113057.png


Input: “Can you extract for me the next information: Name, DOB, from this text: My name is abc and my birthday is 12/26/2000“

Fields to extract: “Name“, “DOB“

Output: “Extracted Name: abc, DOB: 12/26/2000 (AI took 1.3 seconds)“

  1. Retrieve variables or specific values from code.

image-20260218-114100.png

Input:

int a = 5;
int b = 10;
int temp;
temp = a;
a = b;
b = temp;
// Now a is 10, and b is 5.

Fields to extract: “Extract variables from code“

Output: “Extracted Extract variables from code: a, b, temp (AI took 1.9 seconds)“

  1. Extract ID or build number from the given text.

image-20260218-114342.png


Input: “All the responses do not have a specific format to display the links, e.g. In some responses JIRA links are shown as SOURCE in some it is shown as HERE and further at some places it is shown by ID AB-1234 and at some places it shows something like Title.“

Fields to extract: “Extract ID from input“

Output: “Extracted Extract ID from given input: AB-1234 (AI took 1.3 seconds)“

 

What You Should Avoid

  1. Don’t use vague or non-descriptive field names.

image-20260218-114523.png

Input: “Extract all the names from the text that follows. Adam, Brayan, Chris, Davis are friends“

Fields to extract: “Field 1“

Output: “Extracted Field 1: Adam“, “Log message: Adam“

  1. Avoid providing contradictory instructions.

image-20260218-114653.png

Input: “Extract all the names from the text that follows. Adam, Brayan, Chris, Davis are friends“

Fields to extract: “Extract all the vowels“

Output: “Extracted Extract all the vowels: Aa, aya, hi, avi (AI took 1.2 seconds)“ // Vowels are incorrect.

  1. Avoid inconsistencies in date formats.

image-20260218-115043.png

Input: “Lionel Andrés Leo Messi; born 24 June 1987“

Fields to extract: “odd numbers“

Output: “No odd numbers found in the input text.“

Guidelines for Using the AI Transform Block

 What You Can Do

  1. Convert data between formats.

image-20260218-120247.png

Input: (Different numbers)

Transform: “Transform the digits into words “

Output: “Transformed input to 4 items (AI took 0 seconds) “, “Transformed value 1: "two"“, “Transformed value 2: "three"“, “Transformed value 3: "four"“, “Transformed value 4: "five"“.

  1. Perform unit or number conversions.

image-20260218-120558.png

Input: “1 Kg“

Transform: “Transform input into lower units of measurement“

Output: “Transformed input to 1000 grams (AI took 0 seconds)“.

  1. Translate text between languages.

image-20260218-120839.png


Input: “Hello, My name is abc“

Transform: “Transform the input text to Spanish“

Output: “Transformed input to Hola, mi nombre es abc (AI took 0 seconds)“.

What You Should Avoid

  1. Don’t attempt unsupported transformations.

image-20260218-121017.png

Input: “Lenovo laptop p155“

Transform: “Transform the input into short summary“

Output: “The request does not specify a transformation operation that matches the defined categories such as string manipulation, text analysis, or any other specific transformation task. 'Transform into a short summary' is ambiguous without further context."

  1. Avoid using outdated conversion rates for currencies.

image-20260218-121158.png

Input: “$ 100“

Transform: “Transform amount into indian rupees“

Output: “Transformed input to ₹ 8,315 (AI took 0 seconds)“. (Not correct as the exchange rate changes daily).

  1. Avoid attempting text-to-image or file format conversions.

image-20260218-121348.png

Input: “This test will perform text to image conversion“

Transform: “Transform text to image“

Output: “The request specifies a text-to-image conversion task, which falls outside the defined transformation operations such as string manipulation, language translation, or data formatting. Text-to-image conversion is not supported as a valid transformation operation in this context.”

Conclusion

Always keep in mind the limitations, such as avoiding unsupported transformations or ambiguous requests, and focus on structured, valid data to optimize your automation processes.

Disclaimer:
AI accuracy is not guaranteed, as it relies on probabilities and the performance of OpenAI’s technology on any given day. While we strive to provide a seamless experience, occasional inaccuracies or errors may occur due to the inherent limitations of the technology. For more details, please refer to OpenAI documentation.

If you have any questions, contact our Priority Support team.