Closed
Description
What are you trying to achieve?
I want to use the I.askGptOnPage()
or I.askGptOnPageFragment()
function to get a response based on the html code passed to the gpt endpoint.
What do you get instead?
No usable response since the html code was not sent properly:
[ { role: 'user', content: 'Is the text "The world’s leading AI-powered developer platform" displayed on the page?' }, { role: 'user', content: 'Within this HTML: [object Promise]' } ]
npx codeceptjs run --verbose --ai
***************************************
nodeInfo: 22.7.0
osInfo: macOS 15.1
cpuInfo: (8) x64 Apple M1
chromeInfo: 128.0.6613.84
edgeInfo: Not Found
firefoxInfo: undefined
safariInfo: 18.0
If you need more detailed info, just run this: npx codeceptjs info
***************************************
CodeceptJS v3.6.5 #StandWithUkraine
Using test root "/Users/tom/workspaces/WebstormProjects/test"
Helpers: Playwright, AI
Plugins: screenshotOnFail, tryTo, retryFailedStep, retryTo, eachElement
askgpt --
[1] Starting recording promises
Timeouts:
› [Session] Starting singleton browser session
test askGptOnPage
I ask gpt on page "Is the text "The world’s leading AI-powered developer platform" displayed on the page?"
⠋ Processing AI request...[
{
role: 'user',
content: 'Is the text "The world’s leading AI-powered developer platform" displayed on the page?'
},
{ role: 'user', content: 'Within this HTML: [object Promise]' }
]
(node:71080) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
It looks like you've pasted an object reference or the text "[object Promise]" instead of the actual HTML code.
To determine if the text "The world’s leading AI-powered developer platform" is displayed on a web page, you need to check the HTML content of that web page.
Please provide the actual HTML code or a relevant portion of it so I can help you check if that specific text is present.
✔ OK in 1919ms
OK | 1 passed // 3s
AI assistant took 2s and used ~1K input tokens. Tokens limit: 10K
- test source code:
Feature('askgpt');
Scenario('test askGptOnPage', ({ I }) => {
I.askGptOnPage('Is the text "The world’s leading AI-powered developer platform" displayed on the page?');
});
Details
- CodeceptJS version: 3.6.5
- NodeJS Version: 22.7.0
- Operating System: macOS 15.1
- @playwright/test: 1.46.1
- Configuration file:
require('dotenv').config();
const { setHeadlessWhen, setCommonPlugins } = require('@codeceptjs/configure');
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);
// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();
/** @type {CodeceptJS.MainConfig} */
exports.config = {
tests: './*_test.js',
output: './output',
helpers: {
Playwright: {
browser: 'chromium',
url: 'https://www.github.com',
show: true
},
AI: {}
},
include: {
I: './steps_file.js'
},
name: 'test',
ai: {
maxTokens: 10000,
request: async (messages) => {
const { AzureOpenAI } = require("openai");
const deployment = process.env.AZURE_DEPLOYMENT_ID;
const endpoint = process.env.AI_API_ENDPOINT
const apiKey = process.env.AZURE_API_KEY;
const apiVersion = "2024-07-01-preview";
const options = { apiKey, endpoint, apiVersion, deployment }
const client = new AzureOpenAI(options);
console.log(messages);
const { choices } = await client.chat.completions.create(
{
messages,
model: '',
max_tokens: 100
}
);
return choices[0]?.message?.content;
}
}
}
Metadata
Metadata
Assignees
Labels
No labels