@azure/playwright package

Alias de type

AuthenticationType

Types d’authentification pris en charge par Azure Playwright.

BrowserConnectOptions

Options de connexion au navigateur pour le service. Cela inclut les options de point de terminaison et les options de connexion.

Exemple

import playwright, { test, expect, BrowserType } from "@playwright/test";
import { getConnectOptions, BrowserConnectOptions } from "@azure/playwright";

test("has title", async ({ browserName }) => {
 const { wsEndpoint, options } : BrowserConnectOptions = 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();
});
BrowserSessionSourceTypeValue

Valeurs d’identifiant source acceptées par Azure dramaturge pour l’option sourceType.

EndpointOptions

Options de point de terminaison pour le service.

OsType

Types de système d’exploitation pris en charge par Azure Playwright.

PlaywrightServiceAdditionalOptions

Options supplémentaires pour le service.

Functions

createAzurePlaywrightConfig(PlaywrightTestConfig<{}, {}>, PlaywrightServiceAdditionalOptions)

Générez une configuration de dramaturge intégrée à Azure Playwright.

Exemple

import { defineConfig } from "playwright/test";
import { createAzurePlaywrightConfig } from "@azure/playwright";
import playwrightConfig from "./playwright.config";

export default defineConfig(playwrightConfig, createAzurePlaywrightConfig(playwrightConfig));

Exemple

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
}));
getConnectOptions(PlaywrightServiceAdditionalOptions)

Obtenez les options de connexion requises pour vous connecter aux navigateurs hébergés dans le cloud d’Azure Playwright.

Exemple

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();
});

Variables

ServiceAuth

Types d’authentification pris en charge sur Azure Playwright

ServiceEnvironmentVariable

Variables d’environnement utilisées par Azure Playwright

ServiceOS

Types d’OS pris en charge sur les navigateurs cloud hébergés par Azure Playwright

Informations relatives à la fonction

createAzurePlaywrightConfig(PlaywrightTestConfig<{}, {}>, PlaywrightServiceAdditionalOptions)

Générez une configuration de dramaturge intégrée à Azure Playwright.

Exemple

import { defineConfig } from "playwright/test";
import { createAzurePlaywrightConfig } from "@azure/playwright";
import playwrightConfig from "./playwright.config";

export default defineConfig(playwrightConfig, createAzurePlaywrightConfig(playwrightConfig));

Exemple

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<{}, {}>

Paramètres

baseConfig

PlaywrightTestConfig<{}, {}>

Configuration du dramaturge de base

options
PlaywrightServiceAdditionalOptions

Options supplémentaires pour le service

Retours

PlaywrightTestConfig<{}, {}>

PlaywrightConfig

getConnectOptions(PlaywrightServiceAdditionalOptions)

Obtenez les options de connexion requises pour vous connecter aux navigateurs hébergés dans le cloud d’Azure Playwright.

Exemple

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>

Paramètres

options
PlaywrightServiceAdditionalOptions

Options supplémentaires pour le service

Retours

BrowserConnectOptions

Détails de variable

ServiceAuth

Types d’authentification pris en charge sur Azure Playwright

ServiceAuth: { ACCESS_TOKEN: "ACCESS_TOKEN", ENTRA_ID: "ENTRA_ID" }

Type

{ ACCESS_TOKEN: "ACCESS_TOKEN", ENTRA_ID: "ENTRA_ID" }

ServiceEnvironmentVariable

Variables d’environnement utilisées par Azure Playwright

ServiceEnvironmentVariable: { PLAYWRIGHT_SERVICE_ACCESS_TOKEN: string, PLAYWRIGHT_SERVICE_URL: string }

Type

{ PLAYWRIGHT_SERVICE_ACCESS_TOKEN: string, PLAYWRIGHT_SERVICE_URL: string }

ServiceOS

Types d’OS pris en charge sur les navigateurs cloud hébergés par Azure Playwright

ServiceOS: { LINUX: "linux", WINDOWS: "windows" }

Type

{ LINUX: "linux", WINDOWS: "windows" }