### Install testingbot-api using npm Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Installs the testingbot-api package from npm. This is the primary step to integrate the TestingBot client library into your NodeJS project. ```shell npm install testingbot-api ``` -------------------------------- ### TestingBot CLI Examples (Bash) Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Provides practical examples of using the TestingBot API CLI for common tasks like creating codeless tests, listing tests, retrieving browser lists, and uploading files. ```bash # Create a codeless test testingbot lab create '{ "name": "Homepage Test", "url": "https://example.com", "cron": "0 0 * * *", "screenshot": true, "ai_prompt": "Test the homepage loads correctly" }' # List recent tests testingbot tests list 0 20 # Get browser list testingbot browsers list web # Upload a file to storage testingbot storage upload ./test-app.zip ``` -------------------------------- ### JavaScript Client Library Examples Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Example usage of the TestingBot JavaScript client library for common API operations. ```APIDOC ## Basic Usage ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: "your-tb-key", api_secret: "your-tb-secret" }); async function runTests() { try { // Get user information const userInfo = await tb.getUserInfo(); console.log('User:', userInfo); // Get available browsers const browsers = await tb.getBrowsers(); console.log('Available browsers:', browsers.length); // Get recent tests const tests = await tb.getTests(0, 10); console.log('Recent tests:', tests.length); // Get test details for the first test if (tests.length > 0) { const testDetails = await tb.getTestDetails(tests[0].session_id); console.log('Test details:', testDetails); } // Upload a file const appUrl = await tb.uploadFile('/path/to/your/app.apk'); console.log('Uploaded file:', appUrl); // Take screenshots const screenshots = await tb.takeScreenshot( 'https://testingbot.com', [{ browserName: 'chrome', version: 'latest', os: 'WIN11' }], '1280x1024' ); console.log('Screenshots:', screenshots); } catch (error) { console.error('Error:', error); } } runTests(); ``` ``` -------------------------------- ### Install and Use TestingBot API CLI (Bash) Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Installs the TestingBot API CLI globally or locally using npm/npx. Provides commands for user, test, codeless test, browser, device, and storage management. ```bash # Install globally for CLI access npm install -g testingbot-api # Or use npx with local installation npx testingbot ``` -------------------------------- ### CLI Usage Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Information on installing and using the TestingBot API command-line interface. ```APIDOC ## CLI Usage ### Installation ```bash # Install globally for CLI access npm install -g testingbot-api # Or use npx with local installation npx testingbot ``` ### Authentication The CLI uses the same authentication methods as the API client: - Environment variables: `TB_KEY` and `TB_SECRET` or `TESTINGBOT_KEY` and `TESTINGBOT_SECRET` - Configuration file: `~/.testingbot` with `api_key` and `api_secret` ### Available Commands ```bash # User management testingbot user info # Get user information testingbot user update # Update user information # Test management testingbot tests list [offset] [limit] # List tests testingbot tests get # Get test details testingbot tests delete # Delete a test testingbot tests stop # Stop a running test # Codeless tests (Lab) testingbot lab list [offset] [limit] # List codeless tests testingbot lab create # Create a codeless test testingbot lab update # Update a codeless test testingbot lab delete # Delete a codeless test # Browsers and devices testingbot browsers list [type] # List browsers (type: all|web|mobile|real) testingbot devices list # List all devices testingbot devices available # List available devices # Storage testingbot storage upload # Upload a file testingbot storage list [offset] [limit] # List stored files testingbot storage delete # Delete a stored file # Help testingbot --help # Show help testingbot --version # Show version ``` ### CLI Examples ```bash # Create a codeless test testingbot lab create '{ "name": "Homepage Test", "url": "https://example.com", "cron": "0 0 * * *", "screenshot": true, "ai_prompt": "Test the homepage loads correctly" }' # List recent tests testingbot tests list 0 20 # Get browser list testingbot browsers list web # Upload a file to storage testingbot storage upload ./test-app.zip ``` ``` -------------------------------- ### Get Physical Devices (Node.js) Source: https://context7.com/testingbot/testingbot-api/llms.txt Fetches lists of physical mobile devices available on TestingBot. Includes options to get all devices, devices available to the account, and details for a specific device. Requires an initialized TestingBot client. ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: process.env.TESTINGBOT_KEY, api_secret: process.env.TESTINGBOT_SECRET }); async function getDeviceInfo() { try { // Get all physical devices const allDevices = await tb.getDevices(); console.log('All devices:', allDevices); // Get devices available to your account const availableDevices = await tb.getAvailableDevices(); console.log('Available devices:', availableDevices.length); // Get specific device details if (availableDevices.length > 0) { const deviceId = availableDevices[0].id; const deviceDetails = await tb.getDevice(deviceId); console.log('Device details:', deviceDetails); } } catch (error) { console.error('Error getting device info:', error); } } getDeviceInfo(); ``` -------------------------------- ### Initialize TestingBot Client (Node.js) Source: https://context7.com/testingbot/testingbot-api/llms.txt Initializes the TestingBot API client using either environment variables or direct credential passing. Ensure 'testingbot-api' is installed. The client can be configured with api_key and api_secret. ```javascript const TestingBot = require('testingbot-api'); // Using environment variables (recommended) process.env.TESTINGBOT_KEY = 'your-api-key'; process.env.TESTINGBOT_SECRET = 'your-api-secret'; const tb = new TestingBot(); // Or pass credentials directly const tb = new TestingBot({ api_key: 'your-api-key', api_secret: 'your-api-secret' }); // Credentials can also be stored in ~/.testingbot file as: // your-api-key:your-api-secret ``` -------------------------------- ### Get Physical Devices Source: https://context7.com/testingbot/testingbot-api/llms.txt Retrieve lists of physical mobile devices available for testing on TestingBot's platform. Includes methods to get all devices, available devices, and specific device details. ```APIDOC ## Get Physical Devices ### Description Retrieve lists of physical mobile devices available for testing. ### Method `tb.getDevices()`, `tb.getAvailableDevices()`, `tb.getDevice(deviceId)` ### Endpoint - `GET /devices` - `GET /devices/available` - `GET /devices/:id` ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the specific device to retrieve. ### Request Example ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: process.env.TESTINGBOT_KEY, api_secret: process.env.TESTINGBOT_SECRET }); async function getDeviceInfo() { try { // Get all physical devices const allDevices = await tb.getDevices(); console.log('All devices:', allDevices); // Get devices available to your account const availableDevices = await tb.getAvailableDevices(); console.log('Available devices:', availableDevices.length); // Get specific device details if (availableDevices.length > 0) { const deviceId = availableDevices[0].id; const deviceDetails = await tb.getDevice(deviceId); console.log('Device details:', deviceDetails); } } catch (error) { console.error('Error getting device info:', error); } } getDeviceInfo(); ``` ### Response #### Success Response (200) - **devices** (array) - An array of device objects, each containing details like model, OS, and status. - **device** (object) - A single device object with detailed information. ### Response Example ```json // Example for getDevices() or getAvailableDevices() [ { "id": "iphone_14_ios_16", "name": "iPhone 14", "os": "iOS", "os_version": "16", "status": "available" } ] // Example for getDevice(deviceId) { "id": "iphone_14_ios_16", "name": "iPhone 14", "os": "iOS", "os_version": "16", "status": "available", "screen_size": "6.1 inches" } ``` ``` -------------------------------- ### Get Builds with TestingBot API Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Retrieves a list of the latest builds, with optional offset and limit for pagination. Supports callback and async/await styles. ```javascript // Callback style tb.getBuilds(offset, limit, function(error, builds) {}); // Async/await style const builds = await tb.getBuilds(); // With pagination const builds = await tb.getBuilds(10, 20); // offset: 10, limit: 20 ``` -------------------------------- ### Session Management Source: https://github.com/testingbot/testingbot-api/blob/master/README.md APIs for managing test sessions, including starting, stopping, and retrieving session information. -------------------------------- ### Get Available Browsers (Node.js) Source: https://context7.com/testingbot/testingbot-api/llms.txt Retrieves lists of available web and mobile browsers from TestingBot's infrastructure. Supports both async/await and callback patterns. Requires an initialized TestingBot client. ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: process.env.TESTINGBOT_KEY, api_secret: process.env.TESTINGBOT_SECRET }); async function listBrowsers() { try { // Get all browsers const allBrowsers = await tb.getBrowsers(); console.log('Total browsers:', allBrowsers.length); // Get only web browsers const webBrowsers = await tb.getBrowsers('web'); console.log('Web browsers:', webBrowsers.length); // Get only mobile browsers const mobileBrowsers = await tb.getBrowsers('mobile'); console.log('Mobile browsers:', mobileBrowsers.length); // Using callback style tb.getBrowsers('web', (error, browsers) => { if (error) { console.error('Error:', error); return; } console.log('Browsers:', browsers); }); } catch (error) { console.error('Failed to get browsers:', error); } } listBrowsers(); ``` -------------------------------- ### Basic JavaScript API Usage with TestingBot Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Demonstrates basic usage of the TestingBot API client in JavaScript, including initialization, getting user info, available browsers, recent tests, test details, uploading files, and taking screenshots. ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: "your-tb-key", api_secret: "your-tb-secret" }); async function runTests() { try { // Get user information const userInfo = await tb.getUserInfo(); console.log('User:', userInfo); // Get available browsers const browsers = await tb.getBrowsers(); console.log('Available browsers:', browsers.length); // Get recent tests const tests = await tb.getTests(0, 10); console.log('Recent tests:', tests.length); // Get test details for the first test if (tests.length > 0) { const testDetails = await tb.getTestDetails(tests[0].session_id); console.log('Test details:', testDetails); } // Upload a file const appUrl = await tb.uploadFile('/path/to/your/app.apk'); console.log('Uploaded file:', appUrl); // Take screenshots const screenshots = await tb.takeScreenshot( 'https://testingbot.com', [{ browserName: 'chrome', version: 'latest', os: 'WIN11' }], '1280x1024' ); console.log('Screenshots:', screenshots); } catch (error) { console.error('Error:', error); } } runTests(); ``` -------------------------------- ### Get Available Browsers Source: https://context7.com/testingbot/testingbot-api/llms.txt Retrieve the list of browsers available for testing on TestingBot's cloud infrastructure. You can filter by 'web' or 'mobile'. ```APIDOC ## Get Available Browsers ### Description Retrieve the list of browsers available for testing on TestingBot's cloud infrastructure. ### Method `tb.getBrowsers(type?, callback?)` ### Endpoint `GET /browsers` ### Parameters #### Query Parameters - **type** (string) - Optional - Filter browsers by type ('web' or 'mobile'). - **callback** (function) - Optional - Callback function for asynchronous operations. ### Request Example ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: process.env.TESTINGBOT_KEY, api_secret: process.env.TESTINGBOT_SECRET }); async function listBrowsers() { try { // Get all browsers const allBrowsers = await tb.getBrowsers(); console.log('Total browsers:', allBrowsers.length); // Get only web browsers const webBrowsers = await tb.getBrowsers('web'); console.log('Web browsers:', webBrowsers.length); // Get only mobile browsers const mobileBrowsers = await tb.getBrowsers('mobile'); console.log('Mobile browsers:', mobileBrowsers.length); // Using callback style tb.getBrowsers('web', (error, browsers) => { if (error) { console.error('Error:', error); return; } console.log('Browsers:', browsers); }); } catch (error) { console.error('Failed to get browsers:', error); } } listBrowsers(); ``` ### Response #### Success Response (200) - **browsers** (array) - An array of browser objects, each containing details like name, version, and platform. ### Response Example ```json [ { "name": "Chrome", "version": "114.0", "os": "Windows 10", "id": "chrome_latest_windows_10" }, { "name": "Firefox", "version": "115.0", "os": "macOS Ventura", "id": "firefox_latest_macos_ventura" } ] ``` ``` -------------------------------- ### Manage Builds - JavaScript Source: https://context7.com/testingbot/testingbot-api/llms.txt Retrieves and manages test builds. Includes fetching recent builds with pagination, getting all tests associated with a specific build, and deleting builds. Requires API key and secret for authentication. ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: process.env.TESTINGBOT_KEY, api_secret: process.env.TESTINGBOT_SECRET }); async function manageBuilds() { try { // Get recent builds with pagination const builds = await tb.getBuilds(0, 10); console.log(`Found ${builds.length} builds`); if (builds.length > 0) { const buildId = builds[0].id; console.log('Build:', { id: builds[0].id, name: builds[0].name, tests: builds[0].tests, createdAt: builds[0].created_at }); // Get all tests for a specific build const buildTests = await tb.getTestsForBuild(buildId); console.log(`Build ${buildId} has ${buildTests.length} tests`); // Delete a build // const deleted = await tb.deleteBuild(buildId); // console.log('Build deleted:', deleted); } } catch (error) { console.error('Error managing builds:', error); } } manageBuilds(); ``` -------------------------------- ### Get Team Settings - JavaScript Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Retrieves the settings for the current TestingBot team. Supports callback and async/await styles. ```javascript // Callback style tb.getTeam(function(error, data) {}); // Async/await style const teamInfo = await tb.getTeam(); ``` -------------------------------- ### Get Codeless Tests - JavaScript Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Retrieves a list of codeless tests configured for the account, with optional pagination. Supports callback and async/await styles. ```javascript // Callback style tb.getCodelessTests(offset, limit, function(error, tests) {}); // Async/await style const tests = await tb.getCodelessTests(0, 10); // offset: 0, limit: 10 ``` -------------------------------- ### Get User Information with TestingBot API Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Retrieves information about the authenticated user. Supports both callback and async/await patterns. ```javascript // Callback style tb.getUserInfo(function(error, userInfo) {}); // Async/await style const userInfo = await tb.getUserInfo(); ``` -------------------------------- ### Get Screenshot List - JavaScript Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Retrieves a list of all screenshots generated for the account, with optional pagination parameters for offset and limit. Supports callback and async/await styles. ```javascript // Callback style tb.getScreenshotList(offset, limit, function(error, screenshots) {}); // Async/await style const screenshots = await tb.getScreenshotList(); // With pagination const screenshots = await tb.getScreenshotList(10, 20); // offset: 10, limit: 20 ``` -------------------------------- ### Get Authentication Hash for Sharing - JavaScript Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Calculates the authentication hash for sharing test detail pages on TestingBot. This is a synchronous method. ```javascript // This method is synchronous and returns the hash directly const hash = tb.getAuthenticationHashForSharing(sessionId); ``` -------------------------------- ### Get Tests for a Specific Build with TestingBot API Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Retrieves all tests associated with a particular build, identified by its build ID. Supports callback and async/await patterns. ```javascript // Callback style tb.getTestsForBuild(buildId, function(error, tests) {}); // Async/await style const tests = await tb.getTestsForBuild(buildId); ``` -------------------------------- ### Get Users in Team - JavaScript Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Retrieves a list of all users belonging to the current TestingBot team. Supports callback and async/await styles. ```javascript // Callback style tb.getUsersInTeam(function(error, users) {}); // Async/await style const users = await tb.getUsersInTeam(); ``` -------------------------------- ### Get List of Stored Files with TestingBot API Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Retrieves a list of files previously uploaded to TestingBot Storage. Supports optional offset and limit parameters for pagination. Available in callback and async/await styles. ```javascript // Callback style tb.getStorageFiles(offset, limit, function(error, fileDetails) {}); // Async/await style const fileDetails = await tb.getStorageFiles(); // With pagination const fileDetails = await tb.getStorageFiles(10, 20); // offset: 10, limit: 20 ``` -------------------------------- ### Get Active Tunnels List with TestingBot API Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Retrieves a list of currently active tunnels. Supports callback and async/await patterns. ```javascript // Callback style tb.getTunnelList(function(error, tunnelList) {}); // Async/await style const tunnelList = await tb.getTunnelList(); ``` -------------------------------- ### Get Test Details with TestingBot API Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Retrieves detailed information for a specific test using its WebDriver SessionID. Supports callback and async/await patterns. ```javascript // Callback style tb.getTestDetails(sessionId, function(error, testDetails) {}); // Async/await style const testDetails = await tb.getTestDetails(sessionId); ``` -------------------------------- ### Manage Tests - JavaScript Source: https://context7.com/testingbot/testingbot-api/llms.txt Allows retrieving, updating, and managing test sessions. Includes fetching recent tests with pagination, getting detailed test information, updating test status, and stopping running tests. Requires API key and secret. ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: process.env.TESTINGBOT_KEY, api_secret: process.env.TESTINGBOT_SECRET }); async function manageTests() { try { // Get recent tests with pagination const offset = 0; const limit = 20; const tests = await tb.getTests(offset, limit); console.log(`Found ${tests.length} tests`); if (tests.length > 0) { const sessionId = tests[0].session_id; // Get detailed test information const testDetails = await tb.getTestDetails(sessionId); console.log('Test details:', { sessionId: testDetails.session_id, browser: testDetails.browser, platform: testDetails.platform, status: testDetails.status, duration: testDetails.duration }); // Update test status - mark as passed const updateData = { 'test[success]': '1', 'test[status_message]': 'All assertions passed', 'test[name]': 'Login Test', 'test[extra]': 'Additional metadata' }; const updated = await tb.updateTest(updateData, sessionId); console.log('Test updated:', updated); // Stop a running test await tb.stopTest(sessionId); console.log('Test stopped'); // Delete a test (use with caution) // await tb.deleteTest(sessionId); } } catch (error) { console.error('Error managing tests:', error); } } manageTests(); ``` -------------------------------- ### Get User Information - JavaScript Source: https://context7.com/testingbot/testingbot-api/llms.txt Retrieves the authenticated user's account information, including first name, last name, email, and minute usage. Requires API key and secret for authentication. ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: process.env.TESTINGBOT_KEY, api_secret: process.env.TESTINGBOT_SECRET }); async function getUserDetails() { try { const userInfo = await tb.getUserInfo(); console.log('User Info:', { firstName: userInfo.first_name, lastName: userInfo.last_name, email: userInfo.email, minutesUsed: userInfo.minutes_used, minutesTotal: userInfo.minutes_total }); return userInfo; } catch (error) { console.error('Error fetching user info:', error); throw error; } } getUserDetails(); ``` -------------------------------- ### Get Latest Tests with TestingBot API Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Retrieves a list of the latest tests. Supports optional offset and limit parameters for pagination. Available in callback and async/await styles. ```javascript // Callback style tb.getTests(offset, limit, function(error, tests) {}); // Async/await style const tests = await tb.getTests(); // With pagination const tests = await tb.getTests(10, 20); // offset: 10, limit: 20 ``` -------------------------------- ### Get User from Team - JavaScript Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Retrieves detailed information about a specific user within the TestingBot team, identified by their user ID. Supports callback and async/await styles. ```javascript // Callback style tb.getUserFromTeam(userId, function(error, user) {}); // Async/await style const user = await tb.getUserFromTeam(userId); ``` -------------------------------- ### Set TestingBot API Credentials Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Demonstrates three methods for setting TestingBot API credentials: environment variables (recommended), constructor options, and a configuration file. ```bash export TESTINGBOT_KEY="your-api-key" export TESTINGBOT_SECRET="your-api-secret" ``` ```javascript const tb = new TestingBot({ api_key: 'your-api-key', api_secret: 'your-api-secret' }); ``` ```text # ~/.testingbot api_key=your-api-key api_secret=your-api-secret ``` -------------------------------- ### TestingBot API CLI Commands (Bash) Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Lists available commands for the TestingBot API CLI, categorized by function such as user management, test management, codeless tests, browsers, devices, and storage. ```bash # User management testingbot user info # Get user information testingbot user update # Update user information # Test management testingbot tests list [offset] [limit] # List tests testingbot tests get # Get test details testingbot tests delete # Delete a test testingbot tests stop # Stop a running test # Codeless tests (Lab) testingbot lab list [offset] [limit] # List codeless tests testingbot lab create # Create a codeless test testingbot lab update # Update a codeless test testingbot lab delete # Delete a codeless test # Browsers and devices testingbot browsers list [type] # List browsers (type: all|web|mobile|real) testingbot devices list # List all devices testingbot devices available # List available devices # Storage testingbot storage upload # Upload a file testingbot storage list [offset] [limit] # List stored files testingbot storage delete # Delete a stored file # Help testingbot --help # Show help testingbot --version # Show version ``` -------------------------------- ### Initialize TestingBot Client Source: https://context7.com/testingbot/testingbot-api/llms.txt Initialize the TestingBot API client with authentication credentials. This can be done using environment variables or by passing credentials directly. ```APIDOC ## Initialize TestingBot Client ### Description Initialize the TestingBot API client with authentication credentials. ### Method `new TestingBot()` ### Parameters #### Constructor Parameters - **api_key** (string) - Required - Your TestingBot API key. - **api_secret** (string) - Required - Your TestingBot API secret. *Alternatively, credentials can be set using environment variables `TESTINGBOT_KEY` and `TESTINGBOT_SECRET`, or stored in `~/.testingbot` file.* ### Request Example ```javascript const TestingBot = require('testingbot-api'); // Using environment variables (recommended) // process.env.TESTINGBOT_KEY = 'your-api-key'; // process.env.TESTINGBOT_SECRET = 'your-api-secret'; // const tb = new TestingBot(); // Or pass credentials directly const tb = new TestingBot({ api_key: 'your-api-key', api_secret: 'your-api-secret' }); ``` ``` -------------------------------- ### Initialize TestingBot Client in NodeJS Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Initializes the TestingBot API client in a NodeJS application, using environment variables for authentication. Supports both callback and async/await patterns. ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: process.env.TESTINGBOT_KEY, api_secret: process.env.TESTINGBOT_SECRET }); ``` -------------------------------- ### Run Test Suite (Bash) Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Command to execute the test suite for the TestingBot API package. Requires TestingBot credentials to be set as environment variables. ```bash npm test ``` -------------------------------- ### Manage Team Settings and Users with TestingBot API Source: https://context7.com/testingbot/testingbot-api/llms.txt Demonstrates how to manage team settings and users via the TestingBot API. This includes retrieving team information, listing users, fetching user details, creating new team members, updating existing members, and resetting user credentials. Requires admin privileges. ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: process.env.TESTINGBOT_KEY, api_secret: process.env.TESTINGBOT_SECRET }); async function manageTeam() { try { // Get team settings const teamInfo = await tb.getTeam(); console.log('Team info:', teamInfo); // Get all users in team const users = await tb.getUsersInTeam(); console.log(`Team has ${users.length} users`); users.forEach(user => { console.log({ id: user.id, name: `${user.first_name} ${user.last_name}`, email: user.email, role: user.role }); }); // Get specific user details if (users.length > 0) { const userId = users[0].id; const userDetails = await tb.getUserFromTeam(userId); console.log('User details:', userDetails); } // Create new team member (admin only) const newUser = { 'user[first_name]': 'Jane', 'user[last_name]': 'Smith', 'user[email]': 'jane.smith@example.com' }; // const createdUser = await tb.createUserInTeam(newUser); // console.log('User created:', createdUser); // Update team member (admin only) // const updateData = { // 'user[first_name]': 'Jane', // 'user[last_name]': 'Doe' // }; // const updated = await tb.updateUserInTeam(userId, updateData); // console.log('User updated:', updated); // Reset user credentials (admin only) // const reset = await tb.resetCredentials(userId); // console.log('Credentials reset:', reset); } catch (error) { console.error('Error managing team:', error); } } manageTeam(); ``` -------------------------------- ### Create and Manage Codeless Tests with TestingBot API Source: https://context7.com/testingbot/testingbot-api/llms.txt Shows how to create, list, update, and delete codeless automated tests using AI-powered test generation through the TestingBot API. It includes configuring test parameters like name, URL, schedule, and AI prompts. ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: process.env.TESTINGBOT_KEY, api_secret: process.env.TESTINGBOT_SECRET }); async function manageCodelessTests() { try { // Create a new codeless test with AI prompt const testConfig = { name: 'E-commerce Checkout Test', url: 'https://example-shop.com', cron: '0 2 * * *', // Run daily at 2 AM screenshot: true, video: true, idletimeout: 90, screenresolution: '1920x1080', ai_prompt: 'Navigate to the products page, add an item to cart, proceed to checkout, and verify the cart total is displayed correctly' }; const createdTest = await tb.createCodelessTest(testConfig); console.log('Codeless test created:', { id: createdTest.id, name: createdTest.name, url: createdTest.url }); // List all codeless tests const tests = await tb.getCodelessTests(0, 10); console.log(`Found ${tests.length} codeless tests`); tests.forEach(test => { console.log({ id: test.id, name: test.name, url: test.url, cron: test.cron, lastRun: test.last_run }); }); // Update a codeless test if (tests.length > 0) { const testId = tests[0].id; const updateData = { test: { name: 'Updated Test Name', cron: '0 12 * * *', ai_prompt: 'Updated test instructions' } }; const updated = await tb.updateCodelessTest(updateData, testId); console.log('Test updated:', updated); // Delete a codeless test // await tb.deleteCodelessTest(testId); // console.log('Test deleted'); } } catch (error) { console.error('Error managing codeless tests:', error); } } manageCodelessTests(); ``` -------------------------------- ### Create Codeless Test - JavaScript Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Creates a new codeless test with specified configurations including name, URL, schedule, and optional settings like screenshots and AI prompts. Supports callback and async/await styles. ```javascript const testData = { name: 'My Codeless Test', // Required: Test name url: 'https://example.com', // Required: URL to test cron: '0 0 * * *', // Optional: Cron schedule screenshot: true, // Optional: Take screenshots video: false, // Optional: Record video idletimeout: 60, // Optional: Idle timeout in seconds screenresolution: '1920x1080', // Optional: Screen resolution ai_prompt: 'Test the login flow' // Optional: AI test agent prompt }; // Callback style tb.createCodelessTest(testData, function(error, result) {}); // Async/await style const result = await tb.createCodelessTest(testData); ``` -------------------------------- ### Create User in Team - JavaScript Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Adds a new user to the TestingBot team. Requires ADMIN privileges. Accepts user data and supports callback and async/await styles. ```javascript const userData = { 'user[first_name]': 'John', 'user[last_name]': 'Doe', 'user[email]': 'john@example.com' }; // Callback style tb.createUserInTeam(userData, function(error, result) {}); // Async/await style const result = await tb.createUserInTeam(userData); ``` -------------------------------- ### Build Management API Source: https://github.com/testingbot/testingbot-api/blob/master/README.md APIs for retrieving and managing your builds and the tests within them. ```APIDOC ## GET /builds ### Description Retrieves a list of your latest builds. ### Method GET ### Endpoint /builds ### Parameters #### Query Parameters - **offset** (integer) - Optional - The number of builds to skip. - **limit** (integer) - Optional - The maximum number of builds to return. ### Response #### Success Response (200) - **builds** (array) - An array of build objects. #### Response Example ```json { "builds": [ { "id": "build1", "status": "completed" }, { "id": "build2", "status": "running" } ] } ``` ## GET /builds/{buildId}/tests ### Description Retrieves the tests associated with a specific build. ### Method GET ### Endpoint /builds/{buildId}/tests ### Parameters #### Path Parameters - **buildId** (string) - Required - The ID of the build. ### Response #### Success Response (200) - **tests** (array) - An array of test objects belonging to the build. #### Response Example ```json { "tests": [ { "id": "test1", "status": "passed" }, { "id": "test2", "status": "failed" } ] } ``` ## DELETE /builds/{buildId} ### Description Deletes a single build, identified by its Build ID. ### Method DELETE ### Endpoint /builds/{buildId} ### Parameters #### Path Parameters - **buildId** (string) - Required - The ID of the build to delete. ### Response #### Success Response (200) - **success** (boolean) - Indicates if the deletion was successful. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### Take Screenshot - JavaScript Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Takes screenshots for specified browsers. Accepts parameters for URL, browser configurations, resolution, wait time, full page option, and callback URL. Supports callback and async/await styles. ```javascript // Callback style tb.takeScreenshot(url, browsers, waitTime, resolution, fullPage, callbackURL, function(error, screenshots) {}); // Async/await style const screenshots = await tb.takeScreenshot( 'https://example.com', // url - required [{ browserName: 'chrome', version: 'latest', os: 'WIN11' }], // browsers - required '1920x1080', // resolution - required 5000, // waitTime (ms) - optional true, // fullPage - optional 'https://your-callback.com' // callbackURL - optional ); ``` -------------------------------- ### Fetch List of Available Browsers Source: https://github.com/testingbot/testingbot-api/blob/master/README.md Retrieves a list of browsers compatible with TestingBot for automated testing. Supports both callback and async/await styles, with an optional type parameter. ```javascript // Callback style tb.getBrowsers(type, function(error, browsers) {}); // Async/await style const browsers = await tb.getBrowsers(); // With optional type parameter (e.g., 'web' or 'mobile') const webBrowsers = await tb.getBrowsers('web'); ``` -------------------------------- ### Storage Management API Source: https://github.com/testingbot/testingbot-api/blob/master/README.md APIs for managing files in TestingBot Storage. ```APIDOC ## POST /storage/upload/local ### Description Uploads a local file to TestingBot Storage. ### Method POST ### Endpoint /storage/upload/local ### Parameters #### Request Body - **localFilePath** (string) - Required - The path to the local file to upload. ### Request Example ```json { "localFilePath": "/path/to/your/file.apk" } ``` ### Response #### Success Response (200) - **appUrl** (string) - The URL of the uploaded file in TestingBot Storage. #### Response Example ```json { "appUrl": "https://storage.testingbot.com/files/your-file-id" } ``` ## POST /storage/upload/remote ### Description Uploads a remote file to TestingBot Storage. ### Method POST ### Endpoint /storage/upload/remote ### Parameters #### Request Body - **remoteFileUrl** (string) - Required - The URL of the remote file to upload. ### Request Example ```json { "remoteFileUrl": "http://example.com/remote/file.zip" } ``` ### Response #### Success Response (200) - **appUrl** (string) - The URL of the uploaded file in TestingBot Storage. #### Response Example ```json { "appUrl": "https://storage.testingbot.com/files/your-file-id" } ``` ## GET /storage/{appUrl} ### Description Retrieves data from a previously uploaded file in TestingBot Storage. ### Method GET ### Endpoint /storage/{appUrl} ### Parameters #### Path Parameters - **appUrl** (string) - Required - The URL of the file in TestingBot Storage. ### Response #### Success Response (200) - **fileDetails** (object) - Details of the file content. #### Response Example ```json { "fileDetails": { "fileName": "file.txt", "size": 1024, "content": "This is the file content." } } ``` ## GET /storage ### Description Retrieves a list of previously uploaded files in TestingBot Storage. ### Method GET ### Endpoint /storage ### Parameters #### Query Parameters - **offset** (integer) - Optional - The number of files to skip. - **limit** (integer) - Optional - The maximum number of files to return. ### Response #### Success Response (200) - **fileDetails** (array) - An array of objects, each containing details of an uploaded file. #### Response Example ```json { "fileDetails": [ { "fileName": "file1.apk", "url": "..." }, { "fileName": "file2.zip", "url": "..." } ] } ``` ``` -------------------------------- ### Create Browser Session Source: https://context7.com/testingbot/testingbot-api/llms.txt Create a remote browser session on TestingBot's infrastructure and obtain the WebSocket URL for connecting a CDP client (e.g., Puppeteer). ```APIDOC ## Create Browser Session ### Description Create a remote browser session and get CDP URL for browser automation. ### Method `tb.createSession(options)` ### Endpoint `POST /sessions` ### Parameters #### Request Body - **options** (object) - Required - Configuration for the browser session. - **capabilities** (object) - Required - Desired browser capabilities. - **browserName** (string) - Required - The name of the browser (e.g., 'chrome', 'firefox'). - **browserVersion** (string) - Optional - The specific browser version (e.g., 'latest', '114.0'). - **platform** (string) - Optional - The operating system platform (e.g., 'WIN11', 'macOS Ventura'). ### Request Example ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: process.env.TESTINGBOT_KEY, api_secret: process.env.TESTINGBOT_SECRET }); async function createBrowserSession() { try { const sessionOptions = { capabilities: { browserName: 'chrome', browserVersion: 'latest', platform: 'WIN11' } }; const session = await tb.createSession(sessionOptions); console.log('Session ID:', session.session_id); console.log('CDP URL:', session.cdp_url); // Use the CDP URL with a CDP client like puppeteer-core // const browser = await puppeteer.connect({ browserWSEndpoint: session.cdp_url }); return session; } catch (error) { console.error('Failed to create session:', error); throw error; } } createBrowserSession(); ``` ### Response #### Success Response (200) - **session_id** (string) - The unique identifier for the created session. - **cdp_url** (string) - The WebSocket URL for the Chrome DevTools Protocol (CDP) connection. ### Response Example ```json { "session_id": "a1b2c3d4e5f67890", "cdp_url": "wss://cdp.testingbot.com/browser/a1b2c3d4e5f67890?token=..." } ``` ``` -------------------------------- ### Take Screenshots with TestingBot API (JavaScript) Source: https://context7.com/testingbot/testingbot-api/llms.txt Automates the process of taking screenshots across specified browser and OS combinations. It takes a URL, browser configurations, resolution, and optional parameters like wait time and callback URL. The function returns a job ID and polls for results, outputting screenshot URLs upon completion. It also allows fetching a list of all previous screenshot jobs. ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: process.env.TESTINGBOT_KEY, api_secret: process.env.TESTINGBOT_SECRET }); async function takeScreenshots() { try { const url = 'https://www.example.com'; const browsers = [ { browserName: 'chrome', version: 'latest', os: 'WIN11' }, { browserName: 'firefox', version: 'latest', os: 'WIN11' }, { browserName: 'safari', version: 'latest', os: 'MONTEREY' } ]; const resolution = '1920x1080'; const waitTime = 5000; // milliseconds const fullPage = true; const callbackURL = 'https://your-server.com/webhook'; const screenshotJob = await tb.takeScreenshot( url, browsers, resolution, waitTime, fullPage, callbackURL ); console.log('Screenshot job created:', screenshotJob.id); // Poll for results let screenshots; let attempts = 0; const maxAttempts = 30; while (attempts < maxAttempts) { screenshots = await tb.retrieveScreenshots(screenshotJob.id); if (screenshots.state === 'done') { console.log('Screenshots ready!'); screenshots.screenshots.forEach(shot => { console.log({ browser: shot.browser, version: shot.version, os: shot.os, imageUrl: shot.image_url, thumbUrl: shot.thumb_url }); }); break; } console.log(`Status: ${screenshots.state}, waiting...`); await new Promise(resolve => setTimeout(resolve, 2000)); attempts++; } // Get list of all previous screenshots const allScreenshots = await tb.getScreenshotList(0, 10); console.log(`Total screenshots: ${allScreenshots.length}`); } catch (error) { console.error('Error taking screenshots:', error); } } takeScreenshots(); ``` -------------------------------- ### Create Browser Session (Node.js) Source: https://context7.com/testingbot/testingbot-api/llms.txt Creates a new remote browser session on TestingBot and returns the session ID and CDP URL. Requires specified capabilities like browserName, browserVersion, and platform. An initialized TestingBot client is necessary. ```javascript const TestingBot = require('testingbot-api'); const tb = new TestingBot({ api_key: process.env.TESTINGBOT_KEY, api_secret: process.env.TESTINGBOT_SECRET }); async function createBrowserSession() { try { const sessionOptions = { capabilities: { browserName: 'chrome', browserVersion: 'latest', platform: 'WIN11' } }; const session = await tb.createSession(sessionOptions); console.log('Session ID:', session.session_id); console.log('CDP URL:', session.cdp_url); // Use the CDP URL with a CDP client like puppeteer-core // const browser = await puppeteer.connect({ browserWSEndpoint: session.cdp_url }); return session; } catch (error) { console.error('Failed to create session:', error); throw error; } } createBrowserSession(); ```