Export tests
Allows you to export tests from Low Code Automation as code in .side
and Nightwatch.js
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_id
in 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.
Request
Request
curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -X GET "https://lcnc-api.browserstack.com/api/v1/test-list"
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.
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.