Skip to content
Merged

Stage #3127

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
2 changes: 1 addition & 1 deletion docs/kane-cli-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: kane-cli-introduction
title: Kane CLI Documentation - Getting Started
sidebar_label: Introduction
description: Kane CLI is an AI-powered command-line tool that runs browser automation tests in plain English: from your terminal, IDE, or CI pipeline.
description: "Kane CLI is an AI-powered command-line tool that runs browser automation tests in plain English: from your terminal, IDE, or CI pipeline."
keywords:
- kane cli
- kaneai
Expand Down
4 changes: 2 additions & 2 deletions docs/kaneai-github-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Create a `.lambdatest/config.yaml` file in the root directory of your repository
project_id: "your_project_id"
folder_id: "your_folder_id"
assignee: your_user_id
environment_id: environment_id
configuration_id: configuration_id
test_url: "https://your-deployed-app-url.com/"
tunnel_name: "your_tunnel_name" # Optional: set if using the same tunnel across PRs
```
Expand All @@ -193,7 +193,7 @@ tunnel_name: "your_tunnel_name" # Optional: set if using the same tunnel across
| `project_id` | The unique identifier for your <BrandName /> Test Manager project |
| `folder_id` | The folder where generated test cases will be organized |
| `assignee` | The <BrandName /> user ID who will be assigned to test runs for executions |
| `environment_id` | The target testing environment (browser, OS, device configurations) |
| `configuration_id` | The target testing environment (browser, OS, device configurations) |
| `test_url` | The base URL of your application under test (your staging or testing environment URL) |
| `tunnel_name` | *(Optional)* The name of the LambdaTest tunnel to use for testing. Set this when the same tunnel is reused across all PRs. Can be overridden per PR using the `--tunnel` flag in the trigger comment. |

Expand Down
148 changes: 107 additions & 41 deletions docs/playwright-android-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Playwright Android automation is supported on <BrandName /> across **Node.js, Ja

:::tip Supported Versions
- Playwright versions **v1.20.0** to **v1.59.0** are supported for Android real device testing (excluding `v1.54.0`).
- **Node.js** uses the `_android.connect()` API. **Java, C#, and Python** use `chromium.connectOverCDP()`. All use stock Playwright packages, no custom forks required.
- **Java, C#, and Python** use the `chromium.connect()` API. **Node.js** supports both `chromium.connect()` and the Android-native `_android.connect()` API. All use stock Playwright packages, no custom forks required.
- Playwright v1.53.0 is currently supported for Playwright C# (for Android & iOS).
:::

Expand Down Expand Up @@ -141,32 +141,100 @@ dotnet add package Microsoft.Playwright

<TabItem value="nodejs" label="Node.js" default>

Node.js supports both the Chromium API (`chromium.connect()`) and the Android-native API (`_android.connect()`).

**Using `chromium.connect()`**

```javascript title="playwright-android-test.js"
const { chromium } = require("playwright");

(async () => {
const capabilities = {
"LT:Options": {
platformName: "android",
deviceName: "Pixel 5",
platformVersion: "11",
isRealMobile: true,
build: "Playwright Android Build",
name: "Playwright Android Test",
user: process.env.LT_USERNAME,
accessKey: process.env.LT_ACCESS_KEY,
network: true,
video: true,
console: true,
playwrightClientVersion: "1.53.0",
},
};

const cdpUrl = `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(
JSON.stringify(capabilities)
)}`;

const browser = await chromium.connect(cdpUrl);
const context = browser.contexts()[0] || (await browser.newContext());
const page = context.pages()[0] || (await context.newPage());

await page.goto("https://duckduckgo.com", { timeout: 30000 });
await page.locator('[name="q"]').fill("LambdaTest");
await page.locator('[name="q"]').press("Enter");
await page.waitForTimeout(3000);

const title = await page.title();
console.log("Page title:", title);

try {
if (title.includes("LambdaTest")) {
await page.evaluate(
(_) => {},
`lambdatest_action: ${JSON.stringify({
action: "setTestStatus",
arguments: { status: "passed", remark: "Title verified" },
})}`
);
}
} catch (e) {
await page.evaluate(
(_) => {},
`lambdatest_action: ${JSON.stringify({
action: "setTestStatus",
arguments: { status: "failed", remark: e.message },
})}`
);
}

await page.close();
await browser.close();
})();
```

**Using `_android.connect()`**

```javascript title="playwright-android-test.js"
const { _android } = require("playwright");

(async () => {
const capabilities = {
"LT:Options": {
"platformName": "android",
"deviceName": "Pixel 5",
"platformVersion": "11",
"isRealMobile": true,
"build": "Playwright Android Build",
"name": "Playwright Android Test",
"user": process.env.LT_USERNAME,
"accessKey": process.env.LT_ACCESS_KEY,
"network": true,
"video": true,
"console": true,
platformName: "android",
deviceName: "Pixel 5",
platformVersion: "11",
isRealMobile: true,
build: "Playwright Android Build",
name: "Playwright Android Test",
user: process.env.LT_USERNAME,
accessKey: process.env.LT_ACCESS_KEY,
network: true,
video: true,
console: true,
playwrightClientVersion: "1.53.0",
},
};

const device = await _android.connect(
`wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(
JSON.stringify(capabilities)
)}`
);
const cdpUrl = `wss://cdp.lambdatest.com/playwright?capabilities=${encodeURIComponent(
JSON.stringify(capabilities)
)}`;

const device = await _android.connect(cdpUrl);
console.log(`Model: ${device.model()}, Serial: ${device.serial()}`);
await device.shell("am force-stop com.android.chrome");

Expand Down Expand Up @@ -203,7 +271,6 @@ const { _android } = require("playwright");
}

await page.close();
await context.close();
await device.close();
})();
```
Expand Down Expand Up @@ -253,7 +320,7 @@ def main():
)

with sync_playwright() as p:
browser = p.chromium.connect_over_cdp(cdp_url)
browser = p.chromium.connect(cdp_url)
context = browser.contexts[0] if browser.contexts else browser.new_context()
page = context.pages[0] if context.pages else context.new_page()

Expand All @@ -278,7 +345,6 @@ def main():
)

page.close()
context.close()
browser.close()

if __name__ == "__main__":
Expand All @@ -302,31 +368,34 @@ import com.microsoft.playwright.*;
import com.google.gson.Gson;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.LinkedHashMap;
import java.util.Map;

public class PlaywrightAndroidTest {
public static void main(String[] args) {
Map<String, Object> ltOptions = Map.of(
"platformName", "android",
"deviceName", "Pixel 5",
"platformVersion", "11",
"isRealMobile", true,
"build", "Playwright Android Build",
"name", "Playwright Android Test",
"user", System.getenv("LT_USERNAME"),
"accessKey", System.getenv("LT_ACCESS_KEY"),
"network", true,
"video", true,
"console", true
);

Map<String, Object> capabilities = Map.of("LT:Options", ltOptions);
Map<String, Object> ltOptions = new LinkedHashMap<>();
ltOptions.put("platformName", "android");
ltOptions.put("deviceName", "Pixel 5");
ltOptions.put("platformVersion", "11");
ltOptions.put("isRealMobile", true);
ltOptions.put("build", "Playwright Android Build");
ltOptions.put("name", "Playwright Android Test");
ltOptions.put("user", System.getenv("LT_USERNAME"));
ltOptions.put("accessKey", System.getenv("LT_ACCESS_KEY"));
ltOptions.put("network", true);
ltOptions.put("video", true);
ltOptions.put("console", true);
ltOptions.put("playwrightClientVersion", "1.53.0");

Map<String, Object> capabilities = new LinkedHashMap<>();
capabilities.put("LT:Options", ltOptions);

String capsJson = new Gson().toJson(capabilities);
String cdpUrl = "wss://cdp.lambdatest.com/playwright?capabilities="
+ URLEncoder.encode(capsJson, StandardCharsets.UTF_8);

try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().connectOverCDP(cdpUrl);
Browser browser = playwright.chromium().connect(cdpUrl);
BrowserContext context = browser.contexts().size() > 0
? browser.contexts().get(0) : browser.newContext();
Page page = context.pages().size() > 0
Expand All @@ -352,7 +421,6 @@ public class PlaywrightAndroidTest {
}

page.close();
context.close();
browser.close();
}
}
Expand All @@ -372,7 +440,6 @@ mvn compile exec:java -Dexec.mainClass="com.lambdatest.PlaywrightAndroidTest"
```csharp title="PlaywrightAndroidTest.cs"
using Microsoft.Playwright;
using System.Text.Json;
using System.Web;

var capabilities = new Dictionary<string, object>
{
Expand All @@ -394,10 +461,10 @@ var capabilities = new Dictionary<string, object>
};

var capsJson = JsonSerializer.Serialize(capabilities);
var cdpUrl = $"wss://cdp.lambdatest.com/playwright?capabilities={HttpUtility.UrlEncode(capsJson)}";
var cdpUrl = $"wss://cdp.lambdatest.com/playwright?capabilities={Uri.EscapeDataString(capsJson)}";

using var playwright = await Playwright.CreateAsync();
var browser = await playwright.Chromium.ConnectOverCDPAsync(cdpUrl);
var browser = await playwright.Chromium.ConnectAsync(cdpUrl);
var context = browser.Contexts.Count > 0
? browser.Contexts[0] : await browser.NewContextAsync();
var page = context.Pages.Count > 0
Expand Down Expand Up @@ -426,7 +493,6 @@ catch (Exception e)
}

await page.CloseAsync();
await context.CloseAsync();
await browser.CloseAsync();
```

Expand Down
6 changes: 6 additions & 0 deletions docs/playwright-ios-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ Playwright test automation on real iOS devices is now supported on <BrandName />

This guide will cover the basics of getting started with Playwright testing on iOS devices on the <BrandName /> platform.

:::info Currently in BETA

Playwright testing on real iOS devices is currently in **Beta**. To enable this feature for your organization, please contact your <span className="doc__lt" onClick={() => window.openLTChatWidget()}>account team</span> to have the feature flag turned on.

:::

:::tip Supported Versions
- Playwright versions **v1.53.0** and above (until **v1.57.0**) are supported for iOS real device testing.
- All languages use the **stock Playwright packages** — no custom forks or client-side changes required.
Expand Down
Loading