Skip to main content
Experience faster, smarter testing with BrowserStack AI Agents. See what your workflow’s been missing. Explore now!
No Result Found
Connect & Get help from fellow developers on our Discord community. Ask the CommunityAsk the Community

Execute tests

Allows you to trigger test suite and get build status.

Trigger test suite

Triggers a test suite based on the specified test suite ID.

POST /api/v1/test-suite/{test_suite_id}/run

Request parameters

In the curl request, replace the YOUR_USERNAME and YOUR_ACCESS_KEY variables with your account’s username and access-key.

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" \
-X POST "https://lcnc-api.browserstack.com/api/v1/test-suite/${TEST_SUITE_ID}/run" \
-H "Content-Type: application/json" \
-d '{
  "base_url": "https://www.browserstack.com/",
  "enableFullUrl": true,
  "local_identifier": "${LOCAL_IDENTIFIER}",
  "environment": "Staging"
}'
  • test_suite_id* string

    Unique identifier of the test suite. Replace test_suite_id in the request path with the ID of the test suite you want to trigger. To get the test suite ID, open the test suite, click View metadata dropdown, and copy the Test suite ID. The response returns a JSON object containing the build_id, which you can use to fetch the test suite execution status.

  • base_url string

    Specify the base URL used to execute the test suite. When you trigger a test suite with base_url in the above API, the system overrides the existing base URLs of all tests in the suite during execution. To execute tests using the full path, enter the complete URL and set the enableFullUrl parameter to true.

  • enableFullUrl boolean

    Set to true to execute the test suite using the full URL provided in base_url. When set to false or omitted, overrides only the domain and port of each recorded test URL with the host URL

  • environment string

    Environment in which to execute the test suite. This allows you to specify different environments such as Staging, Production, etc.

  • local_identifier string

    Unique identifier of the local tunnel.

Response attributes 200 application/json

Response

{
    "build_id" : "315d0cfdf7d77a42243ff87c0d6764cc8d3f9b09",
    "build_name" : "Smoke Suite-1",
    "test_suite_details": {
        "test_suite_id" : "315d0cfdf7d77a42243ff87c0d6764cc8d3f9b09",
        "name" : "Smoke Suite",
        "description" : "Contains P0, P1 cases for Home page",
        "execution_browsers" : ["chrome", "firefox", "edge", "safari"],
        "host_url" : "",
        "local" : false,
        "tests" : [
            {
                "test_id" : "315d0cfdf7d77a42243ff87c0d6764cc8d3f9b09",
                "name" : "Sample Test 01 | Buy iPhone 14 on apple",
                "url" : "https://apple.com"
            },
            {
                "test_id" : "315d0cfdf7d77a42243ff87c0d6764cc8d3fj38j",
                "name" : "Sample Test 02 | Bstackdemo add to cart",
                "url" : "https://bstackdemo.com"
            }
        ]
    }
}

Fetch build status

Fetches the build status based on the specified build ID. You can get the build ID using the Trigger test suite endpoint.

GET /api/v1/builds/{build_id}/status

Request parameters

In the curl request, replace the YOUR_USERNAME and YOUR_ACCESS_KEY variables with your account’s username and access-key.

Request

curl -u "YOUR_USERNAME:YOUR_ACCESS_KEY" -X GET "https://lcnc-api.browserstack.com/api/v1/builds/{build_id}/status"
  • build_id* string

    Unique identifier of the test build. Replace build_id in the request path with build_id value you receive from the Trigger test suite API.

Response attributes 200 application/json

Response

{
    "build_status": "passed",
    "triggered_by" : "demo_user@example.com",  // "scheduler" in case triggered by scheduler
    "triggered_at" : "2024-03-07T07:36:02.695Z",
    "build_execution_summary": {
        "total": 12,
        "passed": 8,
        "failed": 4,
        "running": 0,
        "queued": 0,
        "duration" : 1200 
    },
    "build_details": {
        "build_id": "315d0cfdf7d77a42243ff87c0d6764cc8d3f9b09",
        "build_name": "Smoke Suite-1",
        "test_executions": [
            {
                "test_id": "315d0cfdf7d77a42243ff87c0d6764cc8d3fj38j",
                "name": "Sample Test 02 | Bstackdemo add to cart",
                "url": "https://bstackdemo.com",
                "test_execution_id": "315d0cfdf7d77a42243ff87c0d6764cc8d3fj38j",
                "device_config": {
                    "type" : "desktop",
                    "browser" : "chrome",
                    "browser_version" : "102.0",
                    "device_name" : "",
                    "real_device" : null
                },
                "status": "passed",
                "duration" : 300, // in seconds
                "scenario_name" : null
            },
            {
                "test_id": "315d0cfdf7d77a42243ff87c0d6764cc8d3fj38j",
                "name": "Sample Test 02 | Bstackdemo add to cart",
                "url": "https://bstackdemo.com",
                "test_execution_id": "315d0cfdf7d77a42243ff87c0d6764cc8d3fj38j",
                "device_config": {
                    "type" : "desktop",
                    "browser" : "safari",
                    "browser_version" : "16.5",
                    "device_name" : "",
                    "real_device" : null
                },
                "status": "passed",
                "duration" : 300,
                "scenario_name" : null
            }
        ]
    },
    "public_build_url": "{PUBLIC_BUILD_URL}", // Note: Public build URL is provided only if the setting is enabled for the project.
    "build_url": "{BUILD_URL}"
}


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.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Download Copy Check Circle