Tosca Framework
Tosca Framework
1. Introduction
A workspace is where all Tosca test cases, modules, and execution logs are stored.
Tosca needs a browser extension to identify & automate web elements in Chrome/Edge.
The System Under Test (SUT) is the application you want to automate.
Examples: Web applications (e.g., Gmail, Amazon), Desktop apps, Mobile apps.
Tosca interacts with the SUT using XScan to capture elements for automation.
We will automate a Login Test Case for a demo website using Tosca.
Username: testuser
Password: Password@123
Click Login Button
XScan is Tosca’s object recognition engine that scans and identifies UI elements (like buttons, input
fields, etc.).
🔹 Property-Based Identification
🔹 Anchor-Based Identification
Control Groups allow us to organize UI elements inside a module for better management.
💡 Example:
A login form can have a control group for:
✔ Text Fields (Username, Password)
✔ Buttons (Login, Forgot Password)
🎯 Next Steps
Data-Driven Testing (DDT) allows running the same test case multiple times with different test data
without modifying the test case structure.
💡 Example TestSheet:
Database-Driven Testing (DBDT) allows test cases to fetch dynamic test data from a database (SQL,
Oracle, etc.) instead of static spreadsheets.
sql
CopyEdit
CREATE TABLE LoginDetails (
Username VARCHAR(50),
Password VARCHAR(50),
ExpectedResult VARCHAR(20)
);
sql
CopyEdit
INSERT INTO LoginDetails VALUES ('user1', 'pass123', 'Success');
INSERT INTO LoginDetails VALUES ('user2', 'pass456', 'Success');
INSERT INTO LoginDetails VALUES ('user3', 'wrongPwd', 'Failure');
sql
CopyEdit
Driver={SQL Server};Server=YourServerName;Database=YourDBName;Trusted_Connection=yes;
sql
CopyEdit
SELECT Username, Password, ExpectedResult FROM LoginDetails;
text
CopyEdit
If ExpectedResult = 'Success', proceed to Dashboard validation
Else, verify error message
Test Step Values define the input data for each test step.
Steps:
1️⃣ Select a Test Step → Click on Test Step Value field.
2️⃣ Enter values for each step (e.g., Username = testuser).
3️⃣ Save the Test Case.
Example in Tosca:
Libraries allow reusing common test steps across multiple test cases.
🔹 Rescan Modules
Business Parameters externalize test data, making test cases data-driven and reusable.
Instead of hardcoding values, Tosca allows parameterization.
Business Parameters pass values dynamically when test cases are executed.
✅ Result: The same test case can be executed multiple times with different credentials.
✅ Example Use Case: Run Login Tests, Checkout Tests, API Tests in a sequence.
✅ Result: Helps in reporting gaps where requirements are not fully tested.
4.While, If, and Do Statements in Tosca
text
CopyEdit
While PageTitle ≠ "Last Page"
Click Next Button
🔹 If-Else Statement
text
CopyEdit
If LoginMessage = "Success"
Verify Dashboard
Else
Capture Error Message
🔹 Do-While Statement
text
CopyEdit
Do Click Submit
While Button ≠ "Enabled"
✅ For Web Applications: Close all browser sessions before starting a test.
✅ For Database Testing: Reset test data before running another test.
🔹 What Is XBuffer?
text
CopyEdit
Set Buffer → {XB[OrderNumber]} = UI Value
Compare {XB[OrderNumber]} with Database Order Number
✅ Result: The test case dynamically compares values without hardcoding them.
text
CopyEdit
//button[contains(text(), "Login")]
text
CopyEdit
ExplicitName = "UserInputField"
🔟 ActionMode Constraint
text
CopyEdit
Verify PageTitle = "WELCOME"
ActionMode = Constraint (Ignores case differences)
✅ Result: Passes even if UI shows "Welcome" or "welcome".
✅ Example: If the "Submit" button is renamed to "Send", Tosca automatically detects & fixes it.
API Testing ensures that the backend services and integrations work as expected. It verifies:
✔️Functionality – API requests return correct data.
✔️Performance – API response times are acceptable.
✔️Security – API is protected against unauthorized access.
✅ URL: https://reqres.in/api/users/2
✅ Steps in Tosca:
1.Add a new GET Request in the TestCase.
2.Enter URL in the request section.
3.Click Run to fetch user details.
4.Validate the response body using Verifications.
json
CopyEdit
{
"name": "John",
"job": "QA Engineer"
}
✅ Steps in Tosca:
1.Add a POST Request module.
2.Enter the API URL.
3.Set Request Headers (e.g., Content-Type: application/json).
4.Enter Request Body using JSON.
5.Execute and verify the Response Code = 201 (Created).
✅ Example of Verification
✅ URL: https://reqres.in/api/users/2
✅ JSON Payload:
json
CopyEdit
{
"name": "John Updated",
"job": "Senior QA Engineer"
}
✅ Steps in Tosca:
1.Create a PUT Request.
2.Enter URL and Request Body.
3.Verify the Response Code = 200 (OK).
✅ URL: https://reqres.in/api/users/2
✅ Steps in Tosca:
1.Add a DELETE Request.
2.Enter the API Endpoint.
3.Execute and verify the Response Code = 204 (No Content).
4.Handling JSON and XML Responses
json
CopyEdit
{
"data": {
"id": 2,
"first_name": "Janet",
"last_name": "Weaver"
}
}
Response.Body.data.first_name = "Janet"
Response.Body.data.id = 2
xml
CopyEdit
<user>
<id>2</id>
<first_name>Janet</first_name>
<last_name>Weaver</last_name>
</user>
Response.Body.user.first_name = "Janet"
Response.Body.user.id = 2
🚀 Result: The test automatically creates, verifies, and deletes a user in one execution!
🔹 Advanced Scenarios
✅ API Authentication Testing (OAuth, Bearer Tokens)
✅ Load Testing APIs (By running execution lists in parallel)
✅ Validating API Security (Unauthorized requests should fail)
yaml
CopyEdit
TestCase Name: Login Functionality
Execution Time: 10:45 AM
Status: ❌ Failed
Error Message: "Element Not Found"
Step 1: Open Browser - ✅ Passed
Step 2: Enter Username - ✅ Passed
Step 3: Enter Password - ✅ Passed
Step 4: Click Login - ❌ Failed
batch
CopyEdit
"%TRICENTIS_HOME%\ToscaCommander.exe" /Execute /Workspace="%WORKSPACE_PATH%"
/ReportPath="C:\JenkinsReports"
yaml
CopyEdit
steps:
- task: CmdLine@2
inputs:
script: 'C:\Program Files (x86)\Tricentis\ToscaCommander.exe /Execute /Workspace="C:\Tosca\
Workspace" /ReportPath="$(Build.ArtifactStagingDirectory)/Reports"'
yaml
CopyEdit
steps:
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)/Reports'
artifactName: 'ToscaReports'
tql
CopyEdit
SELECT * FROM ExecutionLogs WHERE Status = "Failed"