Working with Tosca Parameters (Buffer, Dynamic Expressions)

πŸ§ͺ Working with Tosca Parameters (Buffer, Dynamic Expressions)

In Tricentis Tosca, parameters help you make your tests flexible, reusable, and data-driven. Two powerful types of parameters in Tosca are:


Buffers


Dynamic Expressions


Let’s understand each one and how to use them effectively.


🟦 1. What is a Buffer in Tosca?

A Buffer is a temporary in-memory storage used to store values during test execution. You can store a value in a buffer and then reuse it anywhere in your test case.


πŸ”Ή When to use:

Save a value from one step and reuse it later


Pass values between test steps or modules


Dynamically build test data


✅ How to Create a Buffer

In a Tosca TestStep, you use the syntax:


text

Copy

Edit

=>BufferName

This saves a value to a buffer.


Example:

Capture an Order ID after placing an order:


text

Copy

Edit

ActionMode: Buffer

Value: =>OrderID

This stores the Order ID in a buffer named OrderID.


✅ How to Use a Buffer

You can reuse the buffer value like this:


text

Copy

Edit

{B[OrderID]}

This fetches the current value of the buffer.


Example:

text

Copy

Edit

Search Order: {B[OrderID]}

🟩 2. What are Dynamic Expressions?

Dynamic Expressions in Tosca allow you to calculate values at runtime, such as dates, random numbers, string manipulation, etc.


πŸ”Ή Syntax:

text

Copy

Edit

{X[<Expression>]}

✅ Common Dynamic Expressions

Purpose Expression Example Output

Current Date {X[Date]} 2025-06-16

Add Days to Date {X[Date + 3]} 2025-06-19

Random Number {X[RandomNumber(1000,9999)]} 5732

Random String {X[RandomString(8)]} aB3xGz9K

Combine Strings {X["User_" + RandomString(4)]} User_K3fL


✅ Use Case Example: Generate a Random Email

text

Copy

Edit

{X["user" + RandomNumber(1000,9999) + "@test.com"]}

Might result in:


css

Copy

Edit

user7584@test.com

🧠 Combine Buffers and Dynamic Expressions

You can store a dynamic value in a buffer for later use:


text

Copy

Edit

=>UserEmail

Value: {X["user" + RandomNumber(1000,9999) + "@mail.com"]}

Later use it as:


text

Copy

Edit

Send to: {B[UserEmail]}

🧰 Practical Use Cases

Task Tool

Store login token for reuse Buffer

Generate unique usernames/emails Dynamic Expressions

Save user ID from registration Buffer

Get today’s or tomorrow’s date Dynamic Expression {X[Date + 1]}

Combine values Buffers + Expressions


✅ Summary

Feature Purpose Syntax Example

Buffer Save and reuse test data at runtime =>MyValue / {B[MyValue]}

Dynamic Expression Generate or calculate data dynamically {X[Date + 3]} or {X[RandomString(6)]}

Comments

Popular posts from this blog

How to Install and Set Up Selenium in Python (Step-by-Step)

Feeling Stuck in Manual Testing? Here’s Why You Should Learn Automation Testing

A Beginner's Guide to ETL Testing: What You Need to Know