auto-playwright
auto-playwright copied to clipboard
Incompatible with Azure OpenAI - "Error: 400 Additional properties are not allowed ('parsed' was unexpected) - 'messages.1'"
Error
1) test.spec.ts:18:5 › search for Spotify and verify results › auto-playwright.ai 'click 'Yes'' ──
Error: 400 Additional properties are not allowed ('parsed' was unexpected) - 'messages.1'
at Function.generate (C:\playwright-ui-tests\node_modules\openai\src\error.ts:72:14)
at OpenAI.makeStatusError (C:\playwright-ui-tests\node_modules\openai\src\core.ts:443:21)
at OpenAI.makeRequest (C:\playwright-ui-tests\node_modules\openai\src\core.ts:507:24)
at ChatCompletionRunner._createChatCompletion (C:\playwright-ui-tests\node_modules\openai\src\lib\AbstractChatCompletionRunner.ts:250:28)
at ChatCompletionRunner._runTools (C:\playwright-ui-tests\node_modules\openai\src\lib\AbstractChatCompletionRunner.ts:418:46)
Code
import { test, expect, chromium } from "@playwright/test";
import { auto } from "auto-playwright";
import { DefaultAzureCredential } from "@azure/identity";
import * as os from "os";
import * as fs from "fs";
import * as path from "path";
import { time } from "console";
// Azure resource and model details
const endpoint = "https://xyz.openai.azure.com/";
const deployment = "gpt-4";
test("search for Spotify and verify results", async () => {
const credential = new DefaultAzureCredential();
const token = await credential.getToken("https://cognitiveservices.azure.com/.default");
const options = {
model: deployment,
openaiBaseUrl: `${endpoint}/openai/deployments/${deployment}`,
openaiDefaultQuery: { 'api-version': "2024-05-01-preview" },
openaiApiKey: token.token
};
// Create a temporary user data directory
const userDataDir = path.join(os.tmpdir(), "playwright-user-data");
fs.mkdirSync(userDataDir, { recursive: true });
// Launch a new Microsoft Edge browser window using the temporary user data directory
const browser = await chromium.launchPersistentContext(userDataDir, {
channel: 'msedge',
headless: false,
});
const page = await browser.newPage();
await page.goto("https://xyz.azurewebsites.net", { waitUntil: "domcontentloaded" });
await auto("click 'Yes'", { page, test }, options);
// Search for "Spotify"
await auto("type 'Spotify' in the main search bar and click Search", { page, test }, options);
// Verify the search results
const expectedResults = [
"Spotify - Music and Podcasts (Spotify AB)",
];
for (const result of expectedResults) {
const resultElement = await page.locator(`text=${result}`);
await expect(resultElement).toBeVisible();
}
// Close the browser context
await browser.close();
// Clean up the temporary user data directory
fs.rmdirSync(userDataDir, { recursive: true });
});
any updates on this issue ? I am getting the same error