Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: AI in UI mode #34476

Open
vitalets opened this issue Jan 25, 2025 · 0 comments
Open

[Feature]: AI in UI mode #34476

vitalets opened this issue Jan 25, 2025 · 0 comments
Assignees
Labels

Comments

@vitalets
Copy link
Contributor

🚀 Feature Request

I propose an enhancement to UI mode to assist in fixing failing tests with AI. It could be a button that sends the failed test context to an AI model and displays the response directly in the interface.

Example

Here’s where such a button could be located:

When the user clicks this button, the UI mode builds the prompt with the following data:

  • test error message
  • code snippet
  • ARIA snapshot of the page

Then, it sends a request to AI model and displays the suggestions directly within the UI mode panel.

Users can customize the model and prompt via the ai section in the playwright.config.js:

export default defineConfig({
  ai: {
    model: 'openai-gpt-4o',
    apiKey: process.env.OPENAI_API_KEY,
    prompt: `Fix the error in the Playwright test: {error} {snippet} {ariaSnapshot}`,
  }
});

I've experimented with this approach by adding a prompt as a regular attachment in the HTML reporter. While it works, it requires copy-pasting the prompt into an AI chat, which isn’t very convenient. However, the workflow itself looks promising. For example, here’s a ChatGPT response that fixes the test:

Embedding this functionality into UI mode would make it far more helpful. Additionally, the Playwright VS Code extension could implement a similar feature, potentially integrating with GitHub Copilot.

Motivation

It will make UI mode more powerful and help us to fix tests faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants