Skip to content

Commit e3ffa9b

Browse files
committed
minor ai improvements
1 parent eedf001 commit e3ffa9b

File tree

4 files changed

+44
-13
lines changed

4 files changed

+44
-13
lines changed

docs/ai.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
permalink: /ai
3-
title: Testing with AI 🪄
3+
title: Testing with AI 🪄
44
---
55

66
# 🪄 Testing with AI
@@ -37,7 +37,7 @@ AI providers have limits on input tokens but HTML pages can be huge. However, so
3737

3838
Even though, the HTML is still quite big and may exceed the token limit. So we recommend using models with at least 16K input tokens, (approx. 50K of HTML text), which should be enough for most web pages. It is possible to strictly limit the size of HTML to not exceed tokens limit.
3939

40-
> ❗AI features require sending HTML contents to AI provider. Choosing one may depend on the descurity policy of your company. Ask your security department which AI providers you can use.
40+
> ❗AI features require sending HTML contents to AI provider. Choosing one may depend on the descurity policy of your company. Ask your security department which AI providers you can use.
4141
4242

4343

@@ -91,7 +91,7 @@ ai: {
9191
model: 'gpt-3.5-turbo-0125',
9292
messages,
9393
});
94-
94+
9595
return completion?.choices[0]?.message?.content;
9696
}
9797
}
@@ -146,7 +146,7 @@ ai: {
146146
model: 'claude-2.1',
147147
max_tokens: 1024,
148148
messages
149-
});
149+
});
150150
return resp.content.map((c) => c.text).join('\n\n');
151151
}
152152
}
@@ -167,7 +167,7 @@ ai: {
167167
const { OpenAIClient, AzureKeyCredential } = require("@azure/openai");
168168

169169
const client = new OpenAIClient(
170-
"https://<resource name>.openai.azure.com/",
170+
"https://<resource name>.openai.azure.com/",
171171
new AzureKeyCredential("<Azure API key>")
172172
);
173173
const { choices } = await client.getCompletions("<deployment ID>", messages);
@@ -260,7 +260,7 @@ async function makeApiRequest(endpoint, deploymentId, messages) {
260260
}
261261
```
262262
263-
### Writing Tests with AI Copilot
263+
## Writing Tests with AI Copilot
264264
265265
If AI features are enabled when using [interactive pause](/basics/#debug) with `pause()` command inside tests:
266266
@@ -302,11 +302,11 @@ GPT will generate code and data and CodeceptJS will try to execute its code. If
302302
303303
This AI copilot works best with long static forms. In the case of complex and dynamic single-page applications, it may not perform as well, as the form may not be present on HTML page yet. For instance, interacting with calendars or inputs with real-time validations (like credit cards) can not yet be performed by AI.
304304
305-
Please keep in mind that GPT can't react to page changes and operates with static text only. This is why it is not ready yet to write the test completely. However, if you are new to CodeceptJS and automated testing AI copilot may help you write tests more efficiently.
305+
Please keep in mind that GPT can't react to page changes and operates with static text only. This is why it is not ready yet to write the test completely. However, if you are new to CodeceptJS and automated testing AI copilot may help you write tests more efficiently.
306306
307307
> 👶 Enable AI copilot for junior test automation engineers. It may help them to get started with CodeceptJS and to write good semantic locators.
308308
309-
### Self-Healing Tests
309+
## Self-Healing Tests
310310
311311
In large test suites, the cost of maintaining tests goes exponentially. That's why any effort that can improve the stability of tests pays itself. That's why CodeceptJS has concept of [heal recipes](./heal), functions that can be executed on a test failure. Those functions can try to revive the test and continue execution. When combined with AI, heal recipe can ask AI provider how to fix the test. It will provide error message, step being executed and HTML context of a page. Based on this information AI can suggest the code to be executed to fix the failing test.
312312
@@ -358,7 +358,7 @@ When execution finishes, you will receive information on token usage and code su
358358
By evaluating this information you will be able to check how effective AI can be for your case.
359359
360360
361-
### Arbitrary GPT Prompts
361+
## Arbitrary Prompts
362362
363363
What if you want to take AI on the journey of test automation and ask it questions while browsing pages?
364364
@@ -412,7 +412,7 @@ npx codeceptjs shell --ai
412412
413413
Also this is availble from `pause()` if AI helper is enabled,
414414
415-
Ensure that browser is started in window mode, then browse the web pages on your site.
415+
Ensure that browser is started in window mode, then browse the web pages on your site.
416416
On a page you want to create PageObject execute `askForPageObject()` command. The only required parameter is the name of a page:
417417
418418
```js
@@ -438,6 +438,8 @@ If page object has `clickForgotPassword` method you can execute it as:
438438
=> page.clickForgotPassword()
439439
```
440440
441+
Here is an example of a session:
442+
441443
```shell
442444
Page object for login is saved to .../output/loginPage-1718579784751.js
443445
Page object registered for this session as `page` variable
@@ -481,11 +483,11 @@ GPT prompts and HTML compression can also be configured inside `ai` section of `
481483
482484
```js
483485
ai: {
484-
// define how requests to AI are sent
486+
// define how requests to AI are sent
485487
request: (messages) => {
486488
// ...
487489
}
488-
// redefine prompts
490+
// redefine prompts
489491
prompts: {
490492
// {}
491493
},

docs/changelog.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,35 @@ layout: Section
77

88
# Releases
99

10+
## 3.6.5
11+
12+
❤️ Thanks all to those who contributed to make this release! ❤️
13+
14+
🛩️ *Features*
15+
* feat(helper): playwright > wait for disabled ([#4412](https://github.com/codeceptjs/CodeceptJS/issues/4412)) - by **[kobenguyent](https://github.com/kobenguyent)**
16+
```
17+
it('should wait for input text field to be disabled', () =>
18+
I.amOnPage('/form/wait_disabled').then(() => I.waitForDisabled('#text', 1)))
19+
20+
it('should wait for input text field to be enabled by xpath', () =>
21+
I.amOnPage('/form/wait_disabled').then(() => I.waitForDisabled("//*[@name = 'test']", 1)))
22+
23+
it('should wait for a button to be disabled', () =>
24+
I.amOnPage('/form/wait_disabled').then(() => I.waitForDisabled('#text', 1)))
25+
26+
Waits for element to become disabled (by default waits for 1sec).
27+
Element can be located by CSS or XPath.
28+
**[param](https://github.com/param)** {CodeceptJS.LocatorOrString} locator element located by CSS|XPath|strict locator. **[param](https://github.com/param)** {number} [sec=1] (optional) time in seconds to wait, 1 by default. **[returns](https://github.com/returns)** {void} automatically synchronized promise through #recorder
29+
```
30+
31+
🐛 *Bug Fixes*
32+
* fix(AI): AI is not triggered ([#4422](https://github.com/codeceptjs/CodeceptJS/issues/4422)) - by **[kobenguyent](https://github.com/kobenguyent)**
33+
* fix(plugin): stepByStep > report doesn't sync properly ([#4413](https://github.com/codeceptjs/CodeceptJS/issues/4413)) - by **[kobenguyent](https://github.com/kobenguyent)**
34+
* fix: Locator > Unsupported pseudo selector 'has' ([#4448](https://github.com/codeceptjs/CodeceptJS/issues/4448)) - by **[anils92](https://github.com/anils92)**
35+
36+
📖 *Documentation*
37+
* docs: setup azure open ai using bearer token ([#4434](https://github.com/codeceptjs/CodeceptJS/issues/4434)) - by **[kobenguyent](https://github.com/kobenguyent)**
38+
1039
## 3.6.4
1140

1241
❤️ Thanks all to those who contributed to make this release! ❤️

docs/community-helpers.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Please **add your own** by editing this page.
4343
* [codeceptjs-slack-reporter](https://www.npmjs.com/package/codeceptjs-slack-reporter) Get a Slack notification when one or more scenarios fail.
4444
* [codeceptjs-browserlogs-plugin](https://github.com/pavkam/codeceptjs-browserlogs-plugin) Record the browser logs for failed tests.
4545
* [codeceptjs-testrail](https://github.com/PeterNgTr/codeceptjs-testrail) - a plugin to integrate with [Testrail](https://www.gurock.com/testrail)
46-
* [codeceptjs-monocart-coverage](https://github.com/cenfun/codeceptjs-monocart-coverage) - a plugin to generate coverage reports, it integrate with [monocart coverage reports](https://github.com/cenfun/monocart-coverage-reports)
4746

4847
## Browser request control
4948
* [codeceptjs-resources-check](https://github.com/luarmr/codeceptjs-resources-check) Load a URL with Puppeteer and listen to the requests while the page is loading. Enabling count the number or check the sizes of the requests.

lib/template/heal.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ heal.addRecipe('ai', {
55
prepare: {
66
html: ({ I }) => I.grabHTMLFrom('body'),
77
},
8+
suggest: true,
89
steps: [
910
'click',
1011
'fillField',

0 commit comments

Comments
 (0)