Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/gitlab-ci-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ import VerifiedTag from '@site/src/component/verifiedTag';
"name": "Code sample 5",
"codeSampleType": "code snippet",
"programmingLanguage": "text",
"text": "$ set LT_ACCESS_KEY=<YOUR_LAMBDATEST_ACCESS_KEY>\n$ set LT_ACCESS_KEY=<YOUR_LAMBDATEST_ACCESS_KEY>"
"text": "$ set LT_USERNAME=<YOUR_LAMBDATEST_USERNAME>\n$ set LT_ACCESS_KEY=<YOUR_LAMBDATEST_ACCESS_KEY>"
},
{
"@type": "SoftwareSourceCode",
Expand Down Expand Up @@ -211,7 +211,7 @@ $ export LT_ACCESS_KEY=<YOUR_LAMBDATEST_ACCESS_KEY>
<VerifiedTag value="Verified" />

```
$ set LT_ACCESS_KEY=<YOUR_LAMBDATEST_ACCESS_KEY>
$ set LT_USERNAME=<YOUR_LAMBDATEST_USERNAME>
$ set LT_ACCESS_KEY=<YOUR_LAMBDATEST_ACCESS_KEY>
```

Expand Down
74 changes: 44 additions & 30 deletions docs/gitlab-integration-with-hyperexecute.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ import VerifiedTag from '@site/src/component/verifiedTag';
"hasPart": [
{
"@type": "SoftwareSourceCode",
"name": "Below is a sample of GitLab YAML created for your reference",
"name": "Sample .gitlab-ci.yml for HyperExecute",
"codeSampleType": "code snippet",
"programmingLanguage": "Shell",
"text": "## Define the image to use (adjust for macOS if needed)\nimage: ubuntu:latest\n\n## Define pipelines (can have multiple pipelines)\npipelines:\n ## Default pipeline (can be named differently)\n default:\n ## Branches to trigger this pipeline on (adjust as needed)\n branches:\n - master\n\n ## Define steps in the pipeline\n steps:\n ## Download Hyperexecute CLI (descriptive name)\n - name: Download Hyperexecute CLI\n script: |\n wget https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute\n chmod u+x hyperexecute\n\n ## Run Hyperexecute tests (descriptive name)\n - name: Run Hyperexecute Tests\n script: |\n ./hyperexecute --user <your_user_name> --key <your_access_key> --config <your_yaml_file_path>"
"programmingLanguage": "YAML",
"text": "stages:\n - test\n\nhyperexecute:\n stage: test\n image: ubuntu:latest\n rules:\n # Run on the default branch (adjust as needed)\n - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH\n before_script:\n # ubuntu:latest does not ship curl, so install it first\n - apt-get update && apt-get install -y curl ca-certificates\n # Download the Linux HyperExecute CLI and make it executable\n - curl -fsSL https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute -o hyperexecute\n - chmod +x hyperexecute\n script:\n # LT_USERNAME and LT_ACCESS_KEY come from the masked CI/CD variables added in step 4\n # Replace <your_yaml_file_path> with the path of your HyperExecute YAML file\n - ./hyperexecute --user \"$LT_USERNAME\" --key \"$LT_ACCESS_KEY\" --config <your_yaml_file_path>"
}
],
"dateModified": "2026-09-09T19:10:37+05:30"
"dateModified": "2026-12-04T12:00:00+05:30"
}) }}
/>

Expand Down Expand Up @@ -127,7 +127,19 @@ To connect your external repository by URL, fill in the required information in
<img loading="lazy" src={require('../assets/images/hyperexecute/integration/ci-cd/gitlab/connect_gitlab_by_url.png').default} alt="Create New Project" width="" height=""/>


### 4. Configure the Pipeline
### 4. Add Your Credentials as CI/CD Variables

Keep your <BrandName /> username and access key out of the pipeline file. Store them as project variables, and the pipeline reads them at run time.

- In your GitLab project, go to **Settings** > **CI/CD**, expand **Variables**, and click **Add variable**. You need the Maintainer role.
- Add a variable with the key `LT_USERNAME` and your <BrandName /> username as the value.
- Add a variable with the key `LT_ACCESS_KEY` and your <BrandName /> access key as the value.
- Keep the visibility of both variables at **Masked**, the default, so GitLab shows `[MASKED]` in job logs instead of the value. GitLab can mask a value only when it is a single line with no spaces and at least 8 characters long. If your username is shorter than 8 characters, set `LT_USERNAME` to **Visible** and keep `LT_ACCESS_KEY` masked.
- If you also select **Protect variable**, the variables are passed only to pipelines that run on protected branches or tags, such as your default branch.

To find your username and access key, see [how to get your username and access key](/support/docs/hyperexecute-how-to-get-my-username-and-access-key/).

### 5. Configure the Pipeline
- To configure the new pipeline that you just created, click the **Configure Pipeline** button in the center of the page.
<img loading="lazy" src={require('../assets/images/hyperexecute/integration/ci-cd/gitlab/configure_gitlab.png').default} alt="Create New Project" width="" height=""/>

Expand All @@ -143,33 +155,35 @@ Below is a sample of GitLab YAML created for your reference:

<VerifiedTag value="Verified" />

```bash
## Define the image to use (adjust for macOS if needed)
image: ubuntu:latest

## Define pipelines (can have multiple pipelines)
pipelines:
## Default pipeline (can be named differently)
default:
## Branches to trigger this pipeline on (adjust as needed)
branches:
- master

## Define steps in the pipeline
steps:
## Download Hyperexecute CLI (descriptive name)
- name: Download Hyperexecute CLI
script: |
wget https://downloads.lambdatest.com/hyperexecute/darwin/hyperexecute
chmod u+x hyperexecute

## Run Hyperexecute tests (descriptive name)
- name: Run Hyperexecute Tests
script: |
./hyperexecute --user <your_user_name> --key <your_access_key> --config <your_yaml_file_path>
```yaml title=".gitlab-ci.yml"
stages:
- test

hyperexecute:
stage: test
image: ubuntu:latest
rules:
# Run on the default branch (adjust as needed)
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
before_script:
# ubuntu:latest does not ship curl, so install it first
- apt-get update && apt-get install -y curl ca-certificates
# Download the Linux HyperExecute CLI and make it executable
- curl -fsSL https://downloads.lambdatest.com/hyperexecute/linux/hyperexecute -o hyperexecute
- chmod +x hyperexecute
script:
# LT_USERNAME and LT_ACCESS_KEY come from the masked CI/CD variables added in step 4
# Replace <your_yaml_file_path> with the path of your HyperExecute YAML file
- ./hyperexecute --user "$LT_USERNAME" --key "$LT_ACCESS_KEY" --config <your_yaml_file_path>
```

### 5. Run Your Job
- **stages:** Lists the stages of the pipeline. This example has one stage, `test`.
- **hyperexecute:** The job that runs your tests. It runs in the `test` stage on the `ubuntu:latest` image.
- **rules:** Runs the job on pushes to the default branch. Change the condition to run it on other branches or on merge requests.
- **before_script:** Installs curl, downloads the Linux build of the HyperExecute CLI and makes it executable.
- **script:** Runs the HyperExecute CLI with your <BrandName /> username and access key, read from the masked variables, and the path of the YAML file created for HyperExecute. For every flag the CLI accepts, see the [HyperExecute CLI guide](/support/docs/hyperexecute-cli-run-tests-on-hyperexecute-grid/).

### 6. Run Your Job
- To commit your changes and run your job, click the **Commit Changes** button.
<p></p>
<img loading="lazy" src={require('../assets/images/hyperexecute/integration/ci-cd/gitlab/new_yaml_file.png').default} alt="Create New Project" width="" height=""/>
Expand Down
106 changes: 105 additions & 1 deletion docs/run-tests-with-chrome-devtools-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,27 @@ import VerifiedTag from '@site/src/component/verifiedTag';
"programmingLanguage": "text",
"text": "Page 1: 15 products\nPage 2: 15 products\nPage 3: 15 products\nPage 4: 15 products\nPage 5: 15 products\nCollected 75 products total\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 (index) \u2502 name \u2502 price \u2502\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524\n\u2502 0 \u2502 'HTC Touch HD' \u2502 '$146.00' \u2502\n\u2502 1 \u2502 'Palm Treo Pro' \u2502 '$337.99' \u2502\n\u2502 2 \u2502 'Canon EOS 5D' \u2502 '$134.00' \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"
},
{
"@type": "SoftwareSourceCode",
"name": "Run the Same CDP Test in Python With Playwright",
"codeSampleType": "code snippet",
"programmingLanguage": "Shell",
"text": "pip install playwright"
},
{
"@type": "SoftwareSourceCode",
"name": "cdp_test.py",
"codeSampleType": "code snippet",
"programmingLanguage": "Python",
"text": "# cdp_test.py\nimport json\nimport os\nfrom urllib.parse import quote\n\nfrom playwright.sync_api import sync_playwright\n\nusername = os.environ[\"LT_USERNAME\"]\naccess_key = os.environ[\"LT_ACCESS_KEY\"]\n\ncapabilities = {\n \"browserName\": \"Chrome\",\n \"browserVersion\": \"latest\",\n \"LT:Options\": {\n \"platformName\": \"Windows 10\",\n \"build\": \"CDP Web Automation\",\n \"name\": \"Product Listing (Python)\",\n \"username\": username,\n \"accessKey\": access_key,\n },\n}\n\nendpoint = (\n f\"wss://{quote(username, safe='')}:{quote(access_key, safe='')}\"\n f\"@cdp.lambdatest.com/puppeteer?capabilities={quote(json.dumps(capabilities), safe='')}\"\n)\n\nBASE = \"https://ecommerce-playground.lambdatest.io/index.php?route=product/category&path=25\"\n\n\ndef set_status(page, status, remark):\n action = {\"action\": \"setTestStatus\", \"arguments\": {\"status\": status, \"remark\": remark}}\n page.evaluate(\"_ => {}\", \"lambdatest_action: \" + json.dumps(action))\n\n\nwith sync_playwright() as p:\n browser = p.chromium.connect_over_cdp(endpoint)\n context = browser.contexts[0]\n page = context.pages[0] if context.pages else context.new_page()\n try:\n page.goto(BASE, wait_until=\"domcontentloaded\")\n page.wait_for_selector(\".product-thumb\")\n names = page.locator(\".product-thumb .caption .title a\").all_inner_texts()\n print(f\"Found {len(names)} products\")\n for name in names[:3]:\n print(name.strip())\n # Mark the test as passed on the TestMu AI dashboard\n set_status(page, \"passed\", f\"Found {len(names)} products\")\n except Exception as e:\n # Mark the test as failed so the dashboard reflects the real outcome\n set_status(page, \"failed\", str(e))\n raise\n finally:\n browser.close()"
},
{
"@type": "SoftwareSourceCode",
"name": "Run the Same CDP Test in Python With Playwright",
"codeSampleType": "code snippet",
"programmingLanguage": "Shell",
"text": "python cdp_test.py"
},
{
"@type": "SoftwareSourceCode",
"name": "Running Web Automation With CDP From an AI Agent",
Expand Down Expand Up @@ -176,7 +197,7 @@ import VerifiedTag from '@site/src/component/verifiedTag';
"text": "Found 15 product images\nSaved product-1.jpg (HTC Touch HD)\nSaved product-2.jpg (Palm Treo Pro)\nSaved product-3.jpg (Canon EOS 5D)\nSaved product-4.jpg (Nikon D300)\nSaved product-5.jpg (iPod Touch)"
}
],
"dateModified": "2026-08-17T11:11:51+05:30"
"dateModified": "2026-12-04T19:05:00+05:30"
}) }}
/>

Expand Down Expand Up @@ -210,6 +231,8 @@ Puppeteer is a CDP client. It connects to a TestMu AI cloud browser over a CDP W
These examples are written in TypeScript. You're free to use plain JavaScript instead (remove the type annotations and save the file as `.js`), or connect over CDP from any other language your stack supports. The connection flow is the same.
:::

Other CDP tools connect to the same `wss://cdp.lambdatest.com/puppeteer` endpoint: Playwright through `connect_over_cdp` ([Python example below](#run-the-same-cdp-test-in-python-with-playwright)), [Playwright CLI and Playwright MCP](/support/docs/browser-cloud-playwright-cli-mcp/), [Browser Use](/support/docs/browser-cloud-browser-use/), and the open-source agent-browser CLI from Vercel Labs, so you can also [run agent-browser over CDP](https://www.testmuai.com/agent-browser/#agent-browser-skill).

**1. Install the Puppeteer client.** `puppeteer-core` connects to a remote browser without downloading a local one.

<VerifiedTag value="Verified" />
Expand Down Expand Up @@ -377,6 +400,87 @@ To view your test results, navigate to the TestMu AI Web Automation dashboard.
<img loading="lazy" src={require('../assets/images/cdp-tests-on-testmuai.webp').default} alt="CDP test execution on TestMu AI" width="1471" height="871" className="doc_img"/>


### Run the Same CDP Test in Python With Playwright

Playwright for Python connects to the same endpoint with `connect_over_cdp`. This script builds the endpoint the same way as `cdp-test.ts`, reads your credentials from the `LT_USERNAME` and `LT_ACCESS_KEY` environment variables you set in step 2, reads the first page of the product listing, and marks the test **passed** or **failed** on the dashboard.

**1. Install Playwright for Python.** It needs Python 3.10 or later.

```bash
pip install playwright
```

**2. Create `cdp_test.py`.**

```python title="cdp_test.py"
# cdp_test.py
import json
import os
from urllib.parse import quote

from playwright.sync_api import sync_playwright

username = os.environ["LT_USERNAME"]
access_key = os.environ["LT_ACCESS_KEY"]

capabilities = {
"browserName": "Chrome",
"browserVersion": "latest",
"LT:Options": {
"platformName": "Windows 10",
"build": "CDP Web Automation",
"name": "Product Listing (Python)",
"username": username,
"accessKey": access_key,
},
}

endpoint = (
f"wss://{quote(username, safe='')}:{quote(access_key, safe='')}"
f"@cdp.lambdatest.com/puppeteer?capabilities={quote(json.dumps(capabilities), safe='')}"
)

BASE = "https://ecommerce-playground.lambdatest.io/index.php?route=product/category&path=25"


def set_status(page, status, remark):
action = {"action": "setTestStatus", "arguments": {"status": status, "remark": remark}}
page.evaluate("_ => {}", "lambdatest_action: " + json.dumps(action))


with sync_playwright() as p:
browser = p.chromium.connect_over_cdp(endpoint)
context = browser.contexts[0]
page = context.pages[0] if context.pages else context.new_page()
try:
page.goto(BASE, wait_until="domcontentloaded")
page.wait_for_selector(".product-thumb")
names = page.locator(".product-thumb .caption .title a").all_inner_texts()
print(f"Found {len(names)} products")
for name in names[:3]:
print(name.strip())
# Mark the test as passed on the TestMu AI dashboard
set_status(page, "passed", f"Found {len(names)} products")
except Exception as e:
# Mark the test as failed so the dashboard reflects the real outcome
set_status(page, "failed", str(e))
raise
finally:
browser.close()
```

:::warning
The endpoint contains your access key. Build it from environment variables when the script runs, and keep it out of logs and version control.
:::

**3. Run it:**

```bash
python cdp_test.py
```

The session appears on the TestMu AI Web Automation dashboard under the build **CDP Web Automation**.

## Running Web Automation With CDP From an AI Agent
***

Expand Down
Loading