Automate WebdriverIO From Plain Language
ai-test-generator-4wdio-js (published on npm as wdio-testgen-from-gherkin-js) converts feature files into a runnable WebdriverIO suite. It reads your .feature content, builds structured step maps, and emits both Page Objects and Mocha specs that follow WebdriverIO conventions.
I rebuilt the repository under the new GitHub name so the project aligns with the broader ai-test-generator family, while keeping the npm package unchanged until the rename cycle is complete.
Key Capabilities
- Scenario-aware generation: Each step becomes a method call or assertion in both the Page Object and the corresponding spec.
- AI-guided naming: Natural language processing produces readable selectors and method names, which leads to cleaner code reviews and faster onboarding.
- Fallback locators: Every selector includes an optional fallback list so brittle attributes can be replaced without rerunning the generator.
- Data extraction: The engine pulls notes and inputs from steps like
When user enters "admin"and injects those values into the generated methods. - Allure reporting ready: Rerun the generator, execute tests, and open the Allure dashboard with bundled scripts.
- Programmatic access: Exported
generateStepMapsandgenerateTestSpecsfunctions allow custom pipelines or CI integrations.
CLI Workflow
git clone git@github.com:amiya-pattnaik/ai-test-generator-4wdio-js.git
cd ai-test-generator-4wdio-js
npm install
npm install -g tsx
npm link
Generate artifacts and reports:
testgen steps --all
testgen tests --all
testgen run --report
Prefer local scripts?
npm run dev:testgen:steps -- --all
npm run dev:testgen:tests -- --all
npm run dev:testgen:run -- --report
Use It In Code
const { generateStepMaps, generateTestSpecs } = require('wdio-testgen-from-gherkin-js');
generateStepMaps({
featuresPath: './features',
outputPath: './stepMaps',
watch: false,
force: true
});
generateTestSpecs({
stepMapDir: './stepMaps',
outputDir: './test',
dryRun: false
});
Keep the existing npm name until the package migration wraps up. Once the new name ships, I will update this guide and the README.
Sample Feature To WebdriverIO Output
Feature Input
Feature: Login
Scenario: User logs in
Given I am on the "login" page
When I fill "userName" with "testuser"
And I fill "password" with "password123"
And I click on "login"
Then I should see "welcomeBanner"
Generated Step Map (excerpt)
{
"scenario": "User logs in",
"steps": [
{ "action": "open", "selectorName": "open", "note": "login" },
{ "action": "setValue", "selectorName": "userNameField", "note": "testuser" },
{ "action": "setValue", "selectorName": "passwordField", "note": "password123" },
{ "action": "click", "selectorName": "loginButton" },
{ "action": "assertVisible", "selectorName": "welcomeBanner" }
]
}
Generated Spec Snippet
describe('login feature tests', () => {
it('user logs in', async () => {
const pageObj = new LoginPage();
await pageObj.open('login');
await pageObj.userNameField.setValue('testuser');
await pageObj.passwordField.setValue('password123');
await pageObj.loginButton.click();
await expect(pageObj.welcomeBanner).toBeDisplayed();
});
});
Share Your Scenarios
Feedback on unsupported actions, selector overrides, or spec formatting is invaluable. Drop your scenarios or open an issue so we can keep improving the generator for modern WebdriverIO teams.