Skip to content

Commit 409e329

Browse files
author
DavertMik
committed
udpated docs
1 parent 12a3d55 commit 409e329

20 files changed

Lines changed: 1037 additions & 1137 deletions

src/content/docs/ai.md

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: Testing with AI 🪄
2+
title: Testing with AI
33
---
44
<!-- Auto-generated by scripts/sync-codeceptjs-docs.mjs from codeceptjs/CodeceptJS@4.x. Do not edit. -->
55
**CodeceptJS is the first open-source test automation framework with AI** features to improve the testing experience. CodeceptJS uses AI provider like OpenAI or Anthropic to auto-heal failing tests, assist in writing tests, and more...
66

77
Think of it as your testing co-pilot built into the testing framework
88

9-
> 🪄 **AI features for testing are experimental**. AI works only for web based testing with Playwright, WebDriver, etc. Those features will be improved based on user's experience.
9+
> This is guide on using AI features inside CodeceptJS. To control CodeceptJS via AI Agents, see [Agentic Testing Guide](/agents/).
1010
1111
## How AI Improves Automated Testing
1212

@@ -161,50 +161,6 @@ The AI SDK supports 20+ providers including:
161161

162162
See [AI SDK Providers](https://ai-sdk.dev/docs/foundations/providers-and-models) for complete list and configuration details.
163163

164-
## Writing Tests with AI Copilot
165-
166-
If AI features are enabled when using [interactive pause](/basics/#debug) with `pause()` command inside tests:
167-
168-
For instance, let's create a test to try ai features via `gt` command:
169-
170-
```
171-
npx codeceptjs gt
172-
```
173-
174-
Name a test and write the code. We will use `Scenario.only` instead of Scenario to execute only this exact test.
175-
176-
```js
177-
Feature('ai')
178-
179-
Scenario.only('test ai features', ({ I }) => {
180-
I.amOnPage('https://getbootstrap.com/docs/5.1/examples/checkout/')
181-
pause()
182-
})
183-
```
184-
185-
Now run the test in debug mode with AI enabled:
186-
187-
```
188-
npx codeceptjs run --debug --ai
189-
```
190-
191-
When pause mode started you can ask GPT to fill in the fields on this page. Use natural language to describe your request, and provide enough details that AI could operate with it. It is important to include at least a space char in your input, otherwise, CodeceptJS will consider the input to be JavaScript code.
192-
193-
```
194-
I.fill checkout form with valid values without submitting it
195-
```
196-
197-
![](/img/fill_form_1.png)
198-
199-
GPT will generate code and data and CodeceptJS will try to execute its code. If it succeeds, the code will be saved to history and you will be able to copy it to your test.
200-
201-
![](/img/fill_form2.png)
202-
203-
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.
204-
205-
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.
206-
207-
> 👶 Enable AI copilot for junior test automation engineers. It may help them to get started with CodeceptJS and to write good semantic locators.
208164

209165
## Self-Healing Tests
210166

@@ -406,9 +362,7 @@ ai: {
406362
407363
CodeceptJS uses three main prompts for AI features:
408364
409-
- `writeStep` - generates test code in interactive pause mode
410365
- `healStep` - suggests fixes for failing tests
411-
- `generatePageObject` - creates page objects from HTML
412366
413367
To customize a prompt, generate it using:
414368
@@ -449,9 +403,7 @@ You can also override prompts programmatically in config:
449403
```js
450404
ai: {
451405
prompts: {
452-
writeStep: (html, input) => [{ role: 'user', content: 'As a test engineer...' }]
453406
healStep: (html, { step, error, prevSteps }) => [{ role: 'user', content: 'As a test engineer...' }]
454-
generatePageObject: (html, extraPrompt = '', rootLocator = null) => [{ role: 'user', content: 'As a test engineer...' }]
455407
}
456408
}
457409
```

src/content/docs/architecture.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { recorder, event, output, container, config } from 'codeceptjs'
3232
| [`recorder`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/recorder.js) | the global promise chain that orders every step |
3333
| [`event`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/event.js) | the event dispatcher and the names of all lifecycle events |
3434
| [`output`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/output.js) | the printer used for all console output |
35+
| [`store`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/store.js) | global state of the run — current test/step, run modes, directories |
3536
| [`helper`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/helper.js) | the base class every helper extends |
3637
| [`actor`](https://github.com/codeceptjs/CodeceptJS/blob/master/lib/actor.js) | the base class behind the `I` object |
3738

@@ -180,6 +181,21 @@ output.log('verbose logging information')
180181

181182
Use these instead of `console.log` so messages respect the chosen verbosity.
182183

184+
## Store
185+
186+
`store` holds the state of the current run — the executing test, suite, and step, the active run modes (`dryRun`, `debugMode`, `workerMode`, …), and the project directories. Listeners, plugins, and helpers read it to know where in the [lifecycle](#events) they are without that information being passed to them:
187+
188+
```js
189+
import { store } from 'codeceptjs'
190+
191+
event.dispatcher.on(event.step.before, () => {
192+
if (store.dryRun) return // no side effects on a dry run
193+
output.debug(`in ${store.currentTest?.title}`)
194+
})
195+
```
196+
197+
CodeceptJS keeps the state fields up to date for you. See the [Store reference](/store) for every field and when to write to it.
198+
183199
## Helpers and the Actor
184200
185201
The `I` object is an **actor** assembled from the enabled helpers. Each `I.method()` call delegates to the matching helper method and is wrapped as a step. Methods whose names start with `_` are private to the helper and not exposed on `I`. To add your own actions, write a [custom helper](/helpers).

src/content/docs/detox.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ CodeceptJS provides next features over standard Detox:
3030

3131
* **Unified API**. The same test can be executed in Appium or Detox. Unified API helps different teams to use the same syntax and easy port tests from one engine to another.
3232
* [Interactive pause](/basics#pause). When starting/stopping an application takes a long time, debugging and writing tests can be hard. CodeceptJS solves this by pausing an execution and letting you try different commands and locators. With this feature a test can be writtern during one running session.
33-
* [Auto-retries](/basics#retries) using `retryFailedStepPlugin` and `I.retry()`
33+
* [Auto-retries](/basics#retries) using the `retryFailedStep` plugin and `step.retry()`
3434
* **Cross-Platform testing** - one test can be executed on different engines. When needed, platform-specific actions and locators can be easily applied.
3535

3636
## A Test

src/content/docs/helpers/appium.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,8 +931,12 @@ I.click('//form/*[@type=submit]');
931931
I.click('Logout', '#nav');
932932
// using strict locator
933933
I.click({css: 'nav a.login'});
934+
// using ARIA role locator
935+
I.click({role: 'button', name: 'Submit'});
934936
```
935937

938+
> ℹ️ ARIA role locators (`{role, name}`) match elements the way assistive technology does and survive markup refactors. See [Locators][17].
939+
936940
#### Parameters
937941

938942
* `locator` **([string][5] | [object][11])** (optional, `'//body'` by default) clickable link or button located by text, or any element located by CSS|XPath|strict locator. (optional, default `'//body'`)
@@ -1029,10 +1033,14 @@ I.fillField('password', secret('123456'));
10291033
I.fillField('form#login input[name=username]', 'John');
10301034
// or by strict locator
10311035
I.fillField({css: 'form#login input[name=username]'}, 'John');
1036+
// by ARIA role locator
1037+
I.fillField({role: 'textbox', name: 'Email'}, 'hello@world.com');
10321038
// within a context
10331039
I.fillField('Name', 'John', '#section2');
10341040
```
10351041

1042+
> ℹ️ ARIA role locators (`{role, name}`) match fields by their accessible name and survive markup refactors. See [Locators][17].
1043+
10361044
#### Parameters
10371045

10381046
* `field` **([string][5] | [object][11])** located by label|name|CSS|XPath|strict locator.
@@ -1183,7 +1191,7 @@ I.scrollIntoView('#submit', { behavior: "smooth", block: "center", inline: "cent
11831191
#### Parameters
11841192

11851193
* `locator` **([string][5] | [object][11])** located by CSS|XPath|strict locator.
1186-
* `scrollIntoViewOptions` **(ScrollIntoViewOptions | [boolean][7])** either alignToTop=true|false or scrollIntoViewOptions. See [https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView][17].
1194+
* `scrollIntoViewOptions` **(ScrollIntoViewOptions | [boolean][7])** either alignToTop=true|false or scrollIntoViewOptions. See [https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView][18].
11871195

11881196
Returns **void** automatically synchronized promise through #recorderSupported only for web testing
11891197

@@ -1213,8 +1221,12 @@ The second parameter is a context (CSS or XPath locator) to narrow the search.
12131221
```js
12141222
I.seeElement('#modal');
12151223
I.seeElement('#modal', '#container');
1224+
// using ARIA role locator
1225+
I.seeElement({role: 'dialog'});
12161226
```
12171227

1228+
> ℹ️ ARIA role locators (`{role, name}`) match elements the way assistive technology does and survive markup refactors. See [Locators][17].
1229+
12181230
#### Parameters
12191231

12201232
* `locator` **([string][5] | [object][11])** located by CSS|XPath|strict locator.
@@ -1397,4 +1409,6 @@ Returns **void** automatically synchronized promise through #recorder
13971409

13981410
[16]: http://webdriver.io/api/mobile/setImmediateValue.html
13991411

1400-
[17]: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
1412+
[17]: /locators#aria-locators
1413+
1414+
[18]: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView

0 commit comments

Comments
 (0)