Closed debdutta-chatterjee closed 8 months ago
@debdutta-chatterjee Can you provide a full test that allows us to repro the issue?
Please find the details
Feature: AI test using zero code
Scenario: Search and verify the first organic search result
And Hit enter
import {Given, When, Then} from '@cucumber/cucumber'
import { pageFixture } from '../../hooks/pageFixture';
import {chromium,test,Page} from '@playwright/test'
import { ai } from '@zerostep/playwright'
let page : Page;
When('Hit enter', async function () {
let browser = await chromium.launch({ headless: false });
page = await browser.newPage();
await page.goto('https://www.google.com');
await ai('Hit enter', { page, test })
});
Error
× And Hit enter # src\test\steps\aiTestStpes.ts:8
Error: test.step() can only be called from a test
at TestTypeImpl._step (C:\Users\path\node_modules\@playwright\test\node_modules\playwright\lib\common\testType.js:192:26)
at C:\Users\path\node_modules\@zerostep\playwright\src\index.ts:34:10
at ai (C:\Users\path\node_modules\@zerostep\playwright\src\index.ts:31:10)
at World.
Note - "path" is system folder path
Can you try putting the When
inside a test
block like in the examples in our repo? I'm not familiar with how the Cucumber library works for Playwright, so I'm unsure of if Cucumber tests will work inside a test
block or not. But as the error states, you need to be within the context of a "test" in order for an ai()
step to work.
When executing the ai step inside cucumber getting the error -> "Error: test.step() can only be called from a test"
Can you please share an example how to call the Ai() functions inside cucumber JS
Sample code I am using