# Chatgpt Playwright Web

> Use when Codex needs to operate the real ChatGPT web UI through Playwright or a saved Chrome login profile, including requests such as "use GPT", "use ChatGPT", "ask GPT", "用 GPT", "幫我問 GPT", opening chatgpt.com, continuing an existing conversation URL, or troubleshooting ChatGPT browser automation on Windows.

- Skill: `tseng-chia-wei/chatgpt-playwright-web` (Agent Skill, multi-file: 23 files)
- Install (CLI): `npx skillmds@latest add tseng-chia-wei/chatgpt-playwright-web`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tseng-chia-wei/chatgpt-playwright-web/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: TSENG-CHIA-WEI (https://skillmd.com/u/tseng-chia-wei)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/tseng-chia-wei/chatgpt-playwright-web

---


# ChatGPT Playwright Web

## Overview

Use the bundled Playwright project at `assets/chatgpt-playwright` to open the real ChatGPT website in Chrome and optionally submit prompts.

This skill is self-contained. The automation code, tests, and helper scripts live inside `assets/chatgpt-playwright`, so another machine can use the skill after copying this folder into the Codex skills directory and running `npm install` once inside the bundled project.

## Trigger Phrases

Treat these as direct triggers for this skill:

- `use GPT`
- `use ChatGPT`
- `ask GPT`
- `help me ask GPT`
- `go ask ChatGPT`
- `open GPT`
- `ask this on GPT`
- `用 GPT`
- `幫我問 GPT`
- `去 GPT 上問`
- `到 GPT 上問問題`
- `開 GPT 對話框`

## Quick Start

When this skill is installed, the bundled project path is:

`<skill-dir>\\assets\\chatgpt-playwright`

If you place this repo under the normal Codex skills directory, the usual path will be:

`$CODEX_HOME\\skills\\chatgpt-playwright-web-skill\\assets\\chatgpt-playwright`

Run these inside `assets/chatgpt-playwright`:

- `npm install`
- `npm test`
- `npm run login`
- `npm run open:saved`
- `npm run ask:saved -- "Reply with OK only."`

Use `npm run login` once per machine, then sign in manually in the Chrome window. Later runs reuse the saved profile under `.state\\profiles\\chatgpt-login`.

## Machine Setup

On a fresh machine:

1. Copy or clone this skill into your Codex skills directory.
2. Open `<skill-dir>\\assets\\chatgpt-playwright`.
3. Run `npm install` to install Playwright and the project dependencies.
4. Run `npm test` once to verify the bundle.
5. Run `npm run login` and complete the sign-in manually in Chrome.
6. After that, use `npm run open:saved` or `npm run ask:saved -- "<prompt>"`.

Important notes:

- This project installs the `playwright` npm package locally through `npm install`.
- The first login must be done by you manually, especially for Google sign-in, 2FA, or CAPTCHA.
- The saved login state stays in `.state\\profiles\\chatgpt-login` and should not be committed.

## Default Behavior

When the user asks to use GPT without more detail:

1. Prefer the saved login profile.
2. If the user gives a question, send it through the real ChatGPT composer.
3. Use `--prompt-file` for Chinese, multiline, or long prompts.
4. Keep the browser open unless a one-shot smoke run is enough.

## Main Commands

Run these from `assets/chatgpt-playwright`:

- `npm run login`
- `npm run open:saved`
- `npm run ask:saved -- "<prompt>"`
- `node src/chatgpt-cli.js ask --saved-profile --prompt-file <path-to-prompt.txt>`

These commands cover the main GPT workflow:

- `npm run login`: open ChatGPT and let the user sign in once
- `npm run open:saved`: reopen ChatGPT with the saved signed-in profile
- `npm run ask:saved -- "<prompt>"`: open ChatGPT and send a one-line prompt
- `node src/chatgpt-cli.js ask --saved-profile --prompt-file <file>`: send a long or multiline prompt from a file

## Existing Conversations

To continue an existing ChatGPT conversation URL with the saved profile:

```bash
node tools/ask-existing-conversation.js --profile-dir "<skill-dir>\\assets\\chatgpt-playwright\\.state\\profiles\\chatgpt-login" --url "<conversation-url>" --prompt-file "<prompt-file>"
```

Useful helpers:

- `node tools/inspect-conversation.js <cdp-port> <conversation-id>`
- `node tools/send-followup.js <cdp-port> <conversation-id> <prompt-file>`
- `node tools/export-latest-answer.js <cdp-port> <conversation-id> <output-file>`

## Guardrails

- Do not validate `https://chatgpt.com/` with raw HTTP probes such as `Invoke-WebRequest`; that path returned `403 Forbidden` during verification.
- Do not use headless mode for this workflow; it tends to trigger Cloudflare waiting pages.
- Do not target the hidden fallback textarea. Use the visible composer selector `div#prompt-textarea[contenteditable="true"][role="textbox"]`.
- Saved-profile mode should use real Chrome plus CDP attach, because Google can reject Playwright-launched webdriver sessions during sign-in.
- Do not commit `assets/chatgpt-playwright/node_modules`, `.state`, prompt dumps, or exported answers into git.

## References

- Failure notes and troubleshooting: `references/flow-notes.md`

