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 GPTuse ChatGPTask GPThelp me ask GPTgo ask ChatGPTopen GPTask 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 installnpm testnpm run loginnpm run open:savednpm 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:
- Copy or clone this skill into your Codex skills directory.
- Open
<skill-dir>\\assets\\chatgpt-playwright. - Run
npm installto install Playwright and the project dependencies. - Run
npm testonce to verify the bundle. - Run
npm run loginand complete the sign-in manually in Chrome. - After that, use
npm run open:savedornpm run ask:saved -- "<prompt>".
Important notes:
- This project installs the
playwrightnpm package locally throughnpm 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-loginand should not be committed.
Default Behavior
When the user asks to use GPT without more detail:
- Prefer the saved login profile.
- If the user gives a question, send it through the real ChatGPT composer.
- Use
--prompt-filefor Chinese, multiline, or long prompts. - Keep the browser open unless a one-shot smoke run is enough.
Main Commands
Run these from assets/chatgpt-playwright:
npm run loginnpm run open:savednpm 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 oncenpm run open:saved: reopen ChatGPT with the saved signed-in profilenpm run ask:saved -- "<prompt>": open ChatGPT and send a one-line promptnode 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:
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 asInvoke-WebRequest; that path returned403 Forbiddenduring 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