@azure/playwright package
类型别名
| AuthenticationType |
Azure Playwright 支持的身份验证类型。 |
| BrowserConnectOptions |
服务的浏览器连接选项。 这包括端点选项和连接选项。 示例
|
| EndpointOptions |
服务的终结点选项。 |
| OsType |
Azure Playwright 支持的 OS 类型。 |
| PlaywrightServiceAdditionalOptions |
服务的其他选项。 |
函数
| create |
生成与 Azure Playwright 集成的剧作家配置。 示例
示例
|
| get |
获取连接到 Azure Playwright 的云托管浏览器所需的连接选项。 示例
|
变量
| Service |
Azure Playwright 支持的认证类型 |
| Service |
Azure Playwright 使用的环境变量 |
| ServiceOS | Azure Playwright 云托管浏览器支持的作系统类型 |
函数详细信息
createAzurePlaywrightConfig(PlaywrightTestConfig<{}, {}>, PlaywrightServiceAdditionalOptions)
生成与 Azure Playwright 集成的剧作家配置。
示例
import { defineConfig } from "playwright/test";
import { createAzurePlaywrightConfig } from "@azure/playwright";
import playwrightConfig from "./playwright.config";
export default defineConfig(playwrightConfig, createAzurePlaywrightConfig(playwrightConfig));
示例
import { defineConfig } from "playwright/test";
import { createAzurePlaywrightConfig, ServiceOS, ServiceAuth } from "@azure/playwright";
import playwrightConfig from "./playwright.config";
import { DefaultAzureCredential } from '@azure/identity';
export default defineConfig(playwrightConfig, createAzurePlaywrightConfig(playwrightConfig, {
credential: new DefaultAzureCredential(),
serviceAuthType: ServiceAuth.ENTRA_ID,
os: ServiceOS.WINDOWS
}));
function createAzurePlaywrightConfig(baseConfig: PlaywrightTestConfig<{}, {}>, options?: PlaywrightServiceAdditionalOptions): PlaywrightTestConfig<{}, {}>
参数
- baseConfig
-
PlaywrightTestConfig<{}, {}>
基本剧作家配置
服务的其他选项
返回
PlaywrightTestConfig<{}, {}>
剧作家配置
getConnectOptions(PlaywrightServiceAdditionalOptions)
获取连接到 Azure Playwright 的云托管浏览器所需的连接选项。
示例
import playwright, { test, expect, BrowserType } from "@playwright/test";
import { getConnectOptions } from "@azure/playwright";
test('has title', async ({ browserName }) => {
const { wsEndpoint, options } = await getConnectOptions();
const browser = await (playwright[browserName] as BrowserType).connect(wsEndpoint, options);
const context = await browser.newContext();
const page = await context.newPage();
await page.goto('https://playwright.dev/');
await expect(page).toHaveTitle(/Playwright/);
await page.close();
await context.close();
await browser.close();
});
function getConnectOptions(options?: PlaywrightServiceAdditionalOptions): Promise<BrowserConnectOptions>
参数
服务的其他选项
返回
Promise<BrowserConnectOptions>
浏览器连接选项
变量详细信息
ServiceAuth
Azure Playwright 支持的认证类型
ServiceAuth: { ACCESS_TOKEN: "ACCESS_TOKEN", ENTRA_ID: "ENTRA_ID" }
类型
{ ACCESS_TOKEN: "ACCESS_TOKEN", ENTRA_ID: "ENTRA_ID" }
ServiceEnvironmentVariable
Azure Playwright 使用的环境变量
ServiceEnvironmentVariable: { PLAYWRIGHT_SERVICE_ACCESS_TOKEN: string, PLAYWRIGHT_SERVICE_URL: string }
类型
{ PLAYWRIGHT_SERVICE_ACCESS_TOKEN: string, PLAYWRIGHT_SERVICE_URL: string }
ServiceOS
Azure Playwright 云托管浏览器支持的作系统类型
ServiceOS: { LINUX: "linux", WINDOWS: "windows" }
类型
{ LINUX: "linux", WINDOWS: "windows" }