
GhostCoder for QA
💬 Suggestions, ideas or problems? Email tarasu2008@gmail.com — or open an issue on GitHub.
GhostCoder is AI ghost text for test automation. It runs on a free local model through Ollama, or on any OpenAI-compatible API.
It covers six things:
- Writes whole Playwright tests from a comment. Any locator it doesn't know yet becomes a clearly marked dummy:
page.locator('TODO: email input').
- Opens a browser, only with your permission, to replace those dummies with real, verified locators. It also reads your source code for hidden error messages and validation rules.
- Reuses your existing page objects before anything else, and can generate new ones.
- Writes a plain-English test case above every test (steps, test data, expected results) and exports them all to Excel (CSV) and Markdown.
- Sets up Excel data-driven tests: a reader utility that needs no npm package, plus a sample
.xlsx with valid, negative and boundary rows.
- Understands the kind of file you're in (tests, page objects, utils, JSON test data, config, CI,
.env) and follows the right rules for it.
Setup (Windows, Mac or Linux)
- Install Ollama from https://ollama.com, then run
ollama pull qwen2.5-coder:1.5b. For better full-test generation, use qwen2.5-coder:7b.
- In VS Code, press
Ctrl+Shift+X, search GhostCoder for QA (ghostcoder-qa.ghostcoder-for-qa) and click Install. In Cursor / Windsurf / VSCodium it comes from Open VSX the same way.
- Press
Ctrl+Shift+P and run GhostCoder: Check Model Connection.
- For locator capture, your test project needs Playwright:
npm i -D @playwright/test and npx playwright install chromium. If Chromium isn't installed, GhostCoder falls back to Edge or Chrome.
Daily flow
// TC-104: login PASS with correct username and password and click on two products and add to cart
Click ✨ Write this test above the comment (or press Ctrl+Alt+G). It works in two stages:
- Understand. The model turns the test case into a list of steps (JSON). GhostCoder then checks that list:
- "two products" really becomes two separate product steps,
- steps the test case didn't ask for (sorting, error checks, closing the browser) are removed,
- a final check is added when one is missing.
- Write. The code is generated from those steps without the model: one
test.step per step, so it's always valid. Elements the project already knows get their real locators; the rest get TODO locators.
Ways to give a test case (all work with ✨ Write this test):
// TC-104: title, // TC: title, // Test: title, // Scenario: title, // SPRIN-2046: title
- Plain requests, no prefix needed:
// create test case for login, // write a test to add two products to cart, // automate the checkout flow, // test that login fails with a wrong password (GhostCoder assigns the TC id)
- Ctrl+Alt+G on any comment line treats that comment (and the comment lines around it) as the test case
- several comment lines: a title plus numbered steps (
// 1. Click the login button, // Expected: …), or Given / When / Then. Clearly written steps are read directly, with no model and no waiting.
- a block comment
/* TC-7: … */
- select any text (a manual test case from Excel or Jira) → right-click → Write Test from Selection
- a whole sheet: right-click an
.xlsx or .csv → Import Manual Test Cases. This gives one test per row and reads columns such as TC ID, Title/Summary, Preconditions, Steps, Test Data and Expected Result.
The steps are kept above the test as the plain-English test case. If something is off, edit the Steps / Expected result lines in plain English and click ↻ Rebuild from steps. The code is regenerated, and locators that are already resolved are kept. Examples of lines it understands:
Enter "standard_user" in the username input · Click the third product add to cart button · Verify the cart badge shows "2" · Verify the page URL contains "inventory"
You can also press Enter and wait for grey text, then press Tab. Keep the cursor still while the ✨ Ghost icon spins: clicking or typing makes VS Code drop the suggestion. If that happens, GhostCoder keeps the answer; put the cursor back and press Alt+\.
- A plain-English TC block is added above the test automatically.
- Click 🔍 Resolve N dummy locators at the top of the file. It's automatic:
- Locators that already exist in your page objects are used first.
- GhostCoder asks once for permission to open a browser (choose Always allow for this project), and asks once per test file for the start URL. You can paste
saucedemo.com; https:// is added for you.
- It captures the page, reads your source code (if it's in the workspace), then runs the test's own steps (types, clicks) and captures again after each one. Error messages and next pages are found without your help.
- Every match is filled in, a wrong
goto('/login') is corrected to the page that was actually captured, and a page object is saved (existing ones are never overwritten).
- Anything not found stays
TODO. Click Pick manually in the summary to choose those.
- Each replaced locator is marked ✅ verified live, 🔵 from a page object, 🟠 code only (verify), or ⚠️ not unique.
- 🧱 Convert to Page Object moves the test's locators into page classes (constructor,
goto() and a login() helper where it fits), adds the imports and const loginPage = new LoginPage(page);, and rewrites the test to use them. A login → products test becomes LoginPage and InventoryPage. Existing page files are reused, and your own code in them is kept. Rename anything with F2.
- 📤 Export writes
test-cases/<file>.csv (opens in Excel) and .md for manual QA and reviews.
If the browser can't reach the page (VPN, unusual login, bot blocking), choose Paste HTML instead: copy the page's outerHTML from DevTools and the same process runs on it.
Data-driven tests with Excel
Write a loop that reads from Excel:
import { readExcel } from '../utils/excel';
for (const row of readExcel('test-data/login.xlsx', 'Login')) {
test(`${row.tcId}: ${row.scenario}`, async ({ page }) => {
await page.getByLabel('Email').fill(row.email);
// ...
});
}
Then click 📊 Create Excel data + reader. GhostCoder creates:
utils/excel.ts, the reader. It has no dependencies, works with files saved by Excel or LibreOffice, and skips rows where run is No.
test-data/login.xlsx, with your columns and 5 sample rows: valid, invalid format, empty, boundary length and special characters.
If you're starting from nothing, run GhostCoder: Create Excel Test Data + Reader Utility. Enter the file name, sheet name and columns, and it also inserts an example data-driven test. Existing files are never overwritten.
Run and heal
Above every test there's ▶ Run, and ▶ Run all at the top of the file. GhostCoder runs Playwright and shows ✅ passed 0.3s or ❌ the reason right above the test.
When a test fails, click 🩺 Heal:
- Locator problems (element not found, a leftover
TODO, filling something that isn't an input, two matches): GhostCoder replays the test in the browser, repairs the locators, and runs it again.
- Wrong start address: the start URL is fixed.
- Different text on the page: GhostCoder shows what the page displays versus what the test expects, because that can be a real bug. It changes the test only if you click Update expected value.
Stop
While GhostCoder is working, the status bar shows ⏹ Stop (or press Ctrl+Alt+S, or run GhostCoder: Stop). It stops the model and closes the capture browser immediately. The Cancel button on progress pop-ups does the same.
Speed
When writing a test, GhostCoder streams the model's answer and stops it as soon as the test is complete, so small models no longer keep writing extra tests. It also sends less context. The progress pop-up shows the lines written so far.
No suggestion, or only one line?
Run GhostCoder: Diagnose (Ctrl+Shift+P). It checks:
- the file type GhostCoder detected (test files must be saved as
*.spec.ts / *.test.ts, or live in a tests/ or e2e/ folder),
- that VS Code inline suggestions are switched on,
- other AI extensions (Copilot, Tabnine, Codeium…) that may be showing their own suggestion instead,
- the model server, plus a live test of the model.
Every request is also written to View → Output → GhostCoder. While GhostCoder is working, the ✨ Ghost item in the status bar spins.
Commands
| Command |
What it does |
| GhostCoder: Resolve Dummy Locators |
Replaces dummy locators: page objects first, then browser capture with a code scan, then pasted HTML |
| GhostCoder: Capture Page → Page Object |
Generates a page object from any page |
| GhostCoder: Add Plain-English Test Cases |
Adds or refreshes TC blocks. Your edits to the title, type, priority, description and preconditions are kept |
| GhostCoder: Export Test Cases |
Writes CSV (Excel) and Markdown for the current file or all test files |
| GhostCoder: Create Excel Test Data + Reader Utility |
Data-driven test setup |
| GhostCoder: Set API Key |
For the OpenAI-compatible provider. Stored in VS Code's secret storage |
Alt+\ |
Ask for a suggestion right now |
Project rules (optional)
Put a .ghostcoder-rules.md file in the project root, for example:
Use test.step names that start with the TC id.
Tag smoke tests with @smoke.
Locators only in pages/*.page.ts.
Privacy
With Ollama, your code never leaves your machine. The browser opens only after you click Open browser. Credentials are always read from process.env, and the plugin never writes them into code or test data.
v0.8.0
- Plain request comments work as test cases (
// create test case for login).
- 🧪 More scenarios CodeLens: adds negative tests (wrong password, each field empty) and boundary tests (256-character input) below a test, each with its own plain-English steps.
- New plan steps:
Verify the page has no accessibility violations (axe; needs npm i -D @axe-core/playwright, import added automatically) and Verify the page matches the saved screenshot (toHaveScreenshot).
- Fix: the spinner / Stop button no longer stays on after the code is written while a GhostCoder message is still open.
v0.9.0
- Login once —
GhostCoder: Set Up Login Once: creates tests/auth.setup.ts (logs in with APP_USERNAME / APP_PASSWORD given at run time — never stored), adds a setup project to playwright.config, keeps playwright/.auth/ and .env out of git, writes an empty .env.example, and makes login tests start logged out. The setup file's locators are filled by 🔍 Resolve like any other test.
- API tests —
GhostCoder: Create API Tests: select a curl command (or right-click an OpenAPI/Swagger .json / .yaml file). One Playwright request test per call/operation with sample bodies and the expected status code. Tokens, API keys and -u user:pass become process.env.API_TOKEN etc. — no secrets in code.
- Export — Excel
.xlsx (Test Cases + Steps sheets), TestRail CSV (template "Test Case (Steps)"), Xray CSV (Jira Test Case Importer), or CSV + Markdown.
- Setup wizard — runs on first install (or
GhostCoder: Setup Wizard): checks Ollama, picks the best coder model, offers a bigger model just for understanding test cases, installs Playwright if missing.
- In plain-English steps,
Enter "$APP_PASSWORD" in the password input reads the value from the environment.
v1.0.0
- Other frameworks —
🔁 Cypress / Selenium / WDIO above any test file with plain-English steps (or GhostCoder: Export Tests to Cypress / Selenium / WebdriverIO). Writes exports/cypress/<name>.cy.js, exports/selenium/<Name>Test.java (JUnit 5) or exports/webdriverio/<name>.e2e.js. Locators you already resolved are translated (CSS / XPath); unresolved ones stay as TODO:. Passwords given as $APP_PASSWORD stay environment reads (Cypress.env, System.getenv, process.env).
- Side panel — the 👻 GhostCoder icon in the activity bar lists every test file and test: ✅ passed, ❌ failed (with the reason), ⚠️ dummy locators still to resolve. Click to jump to a test; ▶ runs it, 🪄 heals a failed one.
- Command line — the same engine without VS Code:
npx ghostcoder write tests/login.spec.ts # write tests under test-case comments
npx ghostcoder check tests # CI gate: exit 1 if TODO locators are left
npx ghostcoder export tests --format testrail # xlsx | testrail | xray | csv | md
npx ghostcoder convert tests --to selenium # cypress | selenium | wdio
npx ghostcoder api openapi.yaml # API tests from curl or OpenAPI
Until it is published to npm, run it from the repository: node path/to/ghostcoder/bin/ghostcoder.js ….
In CI (GitHub Actions):
- run: node ghostcoder/bin/ghostcoder.js check tests # fails the job if dummy locators remain
- run: node ghostcoder/bin/ghostcoder.js export tests --format xray --out test-cases
- uses: actions/upload-artifact@v4
with: { name: test-cases, path: test-cases }
Suggestions and feedback are welcome: tarasu2008@gmail.com — Thennarasu Dinamani.
| |