Export tests
Allows you to export tests from Low Code Automation as code in .side and Nightwatch.js format, or as plain-text test cases in CSV format.
Get test scripts by ID
Fetches the test details based on the specified test ID and format.
Request parameters
Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -X GET "https://lcnc-api.browserstack.com/api/v1/tests/{test_id}/export?format=side"
-
test_id* String
Unique identifier of the test. Replace
test_idin the request path with your test ID. -
format String
Specify the export format of the test script. The possible values are
side(Selenium IDE) andnightwatch(Nightwatch.js format). The default is set toside.
Response in side format 200 application/json
Response in side format
{
"id": "example-project",
"version": "2.0",
"name": "Example Project",
"url": "https://www.browserstack.com",
"tests": [
{
"id": "bebf705c719ec37af1b35e7e9102b68927823781",
"name": "Sample login test",
"description": "",
"tags": [],
"commands": [
{
"id": "de45d6cf-ac65-422b-9f5c-fa58d25ee036",
"comment": "Step 1: Open page <strong>\"BrowserStack Login\"</strong>",
"command": "open",
"targets": [],
"target": "https://www.browserstack.com",
"value": ""
},
{
"id": "1a7ee0b3-d98a-4092-8668-12ee50696b7d",
"comment": "Set Resolution",
"command": "setWindowSize",
"targets": [],
"target": "1440x875",
"value": ""
},
{
"id": "83b2f3e4-aaf6-4d6c-bf05-009a38ac7e52",
"comment": "#ToDo: Setup browser locale",
"command": "echo",
"targets": [],
"target": "This step type is currently not supported",
"value": ""
},
{
"id": "3dd21323-909b-441c-a3b0-9139226984fc",
"comment": "Step 2: Click on <strong>\"Accept all\"</strong> button",
"command": "click",
"targets": [],
"target": "xpath=//HTML/BODY[1]/DIV[5]/DIV[2]/DIV[1]/DIV[1]/DIV[2]/DIV[1]/DIV[1]/BUTTON[2]",
"value": ""
},
{
"id": "32b41b22-1be7-491d-9385-5a459feb87bc",
"comment": "Step 3: Click on <strong>\"Enter your email\"</strong> email input",
"command": "click",
"targets": [],
"target": "xpath=//HTML/BODY[1]/DIV[1]/SECTION[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/FORM[1]/DIV[1]/INPUT[1]",
"value": ""
},
{
"id": "5672d944-8f49-41fe-80d7-bcabbdd56414",
"comment": "Step 4: Type <strong>\"random@example.com\"</strong> in <strong>\"Enter your email\"</strong> email input",
"command": "type",
"targets": [],
"target": "xpath=//HTML/BODY[1]/DIV[1]/SECTION[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/FORM[1]/DIV[1]/INPUT[1]",
"value": "rajesh.p.chilka@gmail.com"
},
{
"id": "3f6fcf5c-b572-4c05-af0d-4b3bf98245c1",
"comment": "Step 5: Click on <strong>\"Log in\"</strong> element",
"command": "click",
"targets": [],
"target": "xpath=//HTML/BODY[1]/DIV[1]/SECTION[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/DIV[1]/FORM[1]/DIV[2]/BUTTON[1]/SPAN[1]",
"value": ""
},
{
"id": "4c4f99ae-7eae-4bee-bd0a-de4b452b1adc",
"comment": "Step 6: Type <strong>\"Test@1234\"</strong> in <strong>\"password\"</strong> input",
"command": "type",
"targets": [],
"target": "xpath=//HTML/BODY[1]/DIV[1]/DIV[1]/DIV[1]/FORM[1]/DIV[1]/DIV[1]/DIV[2]/INPUT[1]",
"value": "P@55w0rd@1234"
},
{
"id": "8c272013-ce52-4730-8de9-b3484f74047e",
"comment": "Step 7: Click on <strong>\"Continue\"</strong> element",
"command": "click",
"targets": [],
"target": "xpath=//HTML/BODY[1]/DIV[1]/DIV[1]/DIV[1]/FORM[1]/DIV[2]/BUTTON[1]/DIV[1]",
"value": ""
},
{
"id": "6300a136-ad7d-4a96-a2aa-6f3ba232c23f",
"comment": "Step 8: Validate element text is <strong>\"Logged in successfully\"</strong>",
"command": "assert",
"targets": [],
"target": "localAssertionResult_95070",
"value": "true"
}
]
}
],
"suites": [
{
"id": "suite-id-1",
"name": "Default Suite",
"persistSession": false,
"parallel": false,
"timeout": 300,
"tests": [
"bebf705c719ec37af1b35e7e9102b68927823781"
]
}
],
"urls": [
"https://www.browserstack.com"
],
"plugins": []
}
Response in Nightwatch.js format 200 application/javascript
Response in Nightwatch.js format
// Test Details
// Name: Sample Test
// Description: This test automates various user interactions on a web page.
// Tags: ["Sample", "Nightwatch", "Automation"]
// Import Nightwatch module
module.exports = {
'Sample Test': function (browser) {
// Set up test resolution and browser locale
browser.resizeWindow(1280, 800); // Set resolution
browser.setLocale('en-US'); // Set browser locale
// Define variables
let localVariable = "sample text";
let moduleVariable = "module data";
let datasetVariable = "dataset row data";
let dynamicVariable = "";
// Secrets (replace with secret names, value is empty)
let secretToken = ""; // Secret name: "API_SECRET_TOKEN"
// Step 1: Open URL
browser.url('https://example.com'); // Navigate to the specified URL
// Step 2: Click
browser.waitForElementVisible('button#submit', 1000)
.click('button#submit'); // Click on an element
// Step 3: Hover
browser.moveToElement('#hoverElement', 10, 10); // Hover on an element
// Step 4: Select dropdown
browser.execute(function() {
// Custom implementation for selecting a dropdown value
document.querySelector('#dropdown').value = 'Option1';
});
// Step 5: Type
browser.setValue('input[name="username"]', 'testuser'); // Type into a field
// Step 6: Key Press
browser.keys(browser.Keys.ENTER); // Simulate Enter key press
// Step 7: Visual validation
// Visual validation step: Take a screenshot or validate the visual appearance
// Step 8: Text validation
browser.assert.containsText('#message', 'Welcome back!'); // Validate text
// Step 9: Element presence validation
browser.assert.elementPresent('div#container'); // Validate element presence
// Step 10: Extract value
browser.getText('div#result', function(result) {
dynamicVariable = result.value; // Store extracted value
});
// Step 11: API Step
// API Step: This is an API step placeholder
// Step 12: Custom Actions JS
browser.execute(function() {
console.log('Executing custom JavaScript action');
});
// Step 13: Create variable
let newVariable = "New variable value"; // Create a new variable
// Step 14: Custom validation
browser.assert.equal(newVariable, "New variable value"); // Perform custom validation
// Step 15: File upload
browser.setValue('input[type="file"]', require('path').resolve(__dirname + '/sample-file.txt'));
// Step 16: If, else-if, else logic
if (localVariable === "sample text") {
browser.assert.containsText('#status', 'Success');
} else if (moduleVariable === "different data") {
browser.assert.containsText('#status', 'Alternative flow');
} else {
browser.assert.containsText('#status', 'Default flow');
}
// Close the browser
browser.end();
}
};
Store the response in a file
To download and store the .side format response in a file, use the following curl command:
Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -X GET "https://lcnc-api.browserstack.com/api/v1/tests/{test_id}/export" -o test.side -L
This command fetches the script for the specified test_id in .side format and saves it as test.side file for easy import into Selenium IDE.
Get all recorded tests
Fetches the list of tests associated with your user group.
Note: To list tests for a single project, with filters and pagination, use List tests in the Low Code Automation Reference API. This endpoint continues to work for existing integrations.
Request parameters
Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -X GET "https://lcnc-api.browserstack.com/api/v1/test-list"
-
paginated Boolean
Set to
trueto paginate the response. Without it, thepage,per_page, andqueryparameters are ignored and the full list is returned. -
page Integer
Page to fetch. Applies only when
paginatedistrue. -
per_page Integer
Number of records per page. Applies only when
paginatedistrue. -
query String
Search query for the test list. Applies only when
paginatedistrue.
Response attributes 200 application/json
Response
[
{
"test_id": "315d0cfdf7d77a422434f87c0d6764cc8d3fj38j",
"name": "Sample Test 02 | Apple add to cart",
"tags": [
"sample",
"smoke"
]
},
{
"test_id": "315d0cfdf7d77a42243ff87c0d6764cc8d3fj347",
"name": "Sample Test 01 | Amazon add to cart",
"tags": [
"sample",
"smoke"
]
},
{
"test_id": "728d0cfdf7d77a42243ff87c0d6764cc8d3fj38j",
"name": "Sample Test 03 | Bstackdemo add to cart",
"tags": [
"sample",
"smoke"
]
}
]
-
test_id String
Unique identifier of the test.
-
name String
Name of the test.
-
tags Array
List of tags associated with the test.
Export a test as plain text
Exports one test as a plain-text test case in a CSV file. You can import this file into a test management tool. The file contains a header row and one test row.
Each row has the following columns, described in CSV format:
- Test Id
- Test Name
- Test Description
- Preconditions
- Steps to perform
- Expected Output
Note: Exporting tests as plain text is available only in the Low Code Automation Pro plan.
Request parameters
Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -X GET "https://lcnc-api.browserstack.com/api/v1/projects/{project_id}/tests/{test_id}/test-case-export"
-
project_id* String
ID of the project that contains the test. Replace
project_idin the request path with your project ID. In your project, click Settings, then General, and copy the value from Project ID in the Project details. -
test_id* String
Unique identifier of the test. Replace
test_idin the request path with your test ID. Click Copy Test ID in the testβs Configurations section, or use the Get all recorded tests endpoint.
Response 200 text/csv
The file is downloaded as lca-test-case-<test_id>.csv.
Response
"Test Id","Test Name","Test Description","Preconditions","Steps to perform","Expected Output"
"ff6ad340a3713a3e46c68a1606fab3a25bd41413",
"Sign in and land on the dashboard",
"Verifies the happy-path login.",
"",
"1. Click on ""Sign in"" element
2. Validate the page heading",
"2. ""Dashboard"" text equals ""Dashboard"""
Export all tests in a project as plain text
Exports every test in a project as a CSV file, one row per test. Results are paginated.
Request parameters
Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -X GET "https://lcnc-api.browserstack.com/api/v1/projects/{project_id}/test-case-export?page=1&per_page=100"
-
project_id* String
ID of the project to export. Replace
project_idin the request path with your project ID. In your project, click Settings, then General, and copy the value from Project ID in the Project details. -
page Integer
Page number to return, starting at 1. Pages are in ascending order of test creation date, so page 1 has the earliest created tests and the last page has the latest. The default is
1. A page beyond the last page returns the last page. -
per_page Integer
Number of tests per page. The default and the maximum are
100. A larger value returns 100 tests per page.
Response 200 text/csv
The file is downloaded as lca-test-cases-p<project_id>-page<page>.csv. The body has the same columns as the single-test export, with one row per test. Pagination details are returned in the response headers.
Export all tests across projects as plain text
Exports every test in every project you have permission to view, as a CSV file with one row per test. Results are paginated.
Request parameters
Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -X GET "https://lcnc-api.browserstack.com/api/v1/test-case-export?page=1&per_page=100"
-
page Integer
Page number to return, starting at 1. Pages are in ascending order of test creation date, so page 1 has the earliest created tests and the last page has the latest. The default is
1. A page beyond the last page returns the last page. -
per_page Integer
Number of tests per page. The default and the maximum are
100. A larger value returns 100 tests per page.
Response 200 text/csv
The file is downloaded as lca-test-cases-page<page>.csv. The body has the same columns as the single-test export, with one row per test. Pagination details are returned in the response headers.
Note: Projects you do not have permission to view are left out. If you cannot view any project, the response is a CSV with only the header row and
X-Total-Count: 0.
Response headers
Every successful plain-text export response carries the following headers:
| Name | Type | Description |
|---|---|---|
X-Page |
Integer | Page returned, starting at 1. |
X-Per-Page |
Integer | Number of tests per page. |
X-Total-Count |
Integer | Total number of tests in the export. |
X-Total-Pages |
Integer | Total number of pages. |
Link |
String | URL of the next page, in the format <url>; rel="next". Absent on the last page. Returned only by the project and all-projects endpoints. |
Pagination works in ascending order of test creation date. Page 1 contains the earliest created tests, and the last page contains the most recently created tests. This keeps the pages stable while you download them. To export everything, start at page=1 and follow the Link header until it is absent.
CSV format
The exported CSV file contains the following columns:
| Column | Description |
|---|---|
| Test Id | Unique identifier of the test. |
| Test Name | Name of the test. |
| Test Description | Description of the test. |
| Preconditions | The testβs configuration, one item per line: request headers, cookies, local storage, browser flags, basic authentication username, linked dataset, base URL, resolution, and emulated device. |
| Steps to perform | The testβs steps as a numbered list. Module steps appear inline as ordinary numbered steps. If, Else, and End If blocks appear as their own numbered entries. |
| Expected Output | The expected result of each validation step, numbered to match its step in Steps to perform. Steps without a validation have no entry. |
The file is UTF-8 encoded with a byte order mark (BOM), every value is enclosed in double quotes, and rows are separated by CRLF, so it opens correctly in Microsoft Excel and Google Sheets. A value that starts with =, +, -, or @ is prefixed with an apostrophe so that spreadsheet applications do not run it as a formula.
Store the plain-text export in a file
To save the CSV to a file, use the -o option:
Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -X GET "https://lcnc-api.browserstack.com/api/v1/projects/{project_id}/test-case-export" -o test-cases.csv
Error responses for plain-text export
Errors are returned as JSON. The following table lists the error status codes and when each one occurs:
| Status | When |
|---|---|
400 |
project_id does not match a project, or page or per_page is not a whole number. |
401 |
The username or access key is missing or incorrect. |
403 |
Your plan does not include test export (Low Code Automation Pro plan required), or you do not have permission to view tests in the project. |
404 |
Single-test export only. The test does not exist, was deleted, or is not in the given project. |
500 |
The export could not be completed. Retry the request. |
Response 403 application/json
Returned when your plan does not include test export.
Response
{
"message": {
"title": "Cannot export test scripts",
"detail": "Please upgrade the plan for export test script feature."
}
}
Response 400 application/json
Response
{
"status": "FAIL",
"message": {
"title": "Bad Request",
"data": "Invalid page: abc"
}
}
Data export limitations
The following are not included in the exported test cases:
- Secret, variable, and dataset values. They are exported as their names, in the format
${name}. - Basic authentication passwords. Only the username is exported.
- Endpoint URLs of API steps, and credentials in any URL.
- Element locators such as XPath and CSS selectors. Steps and expected results describe elements by their label.
- AI-generated test data. It is exported as
[AI-generated value].
If a test cannot be exported, its row is still included, with [Test could not be exported] or [No test data found for this test] in place of its content, so the number of rows always matches X-Total-Count.
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.