codeceptjs
Advanced tools
Changelog
3.5.11
❤️ Thanks all to those who contributed to make this release! ❤️
🛩️ Features
🐛 Bug Fixes
📖 Documentation
Changelog
3.5.10
❤️ Thanks all to those who contributed to make this release! ❤️
🛩️ Features
Now we expose the WebElements that are returned by the WebHelper and you could make the subsequence actions on them.
// Playwright helper would return the Locator
I.amOnPage('/form/focus_blur_elements');
const webElements = await I.grabWebElements('#button');
webElements[0].click();
Replaying from HAR
// Replay API requests from HAR.
// Either use a matching response from the HAR,
// or abort the request if nothing matches.
I.replayFromHar('./output/har/something.har', { url: "*/**/api/v1/fruits" });
I.amOnPage('https://demo.playwright.dev/api-mocking');
I.see('CodeceptJS');
[Parameters]
harFilePath [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) Path to recorded HAR file
opts [object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)? [Options for replaying from HAR](https://playwright.dev/docs/api/class-page#page-route-from-har)
A HAR file is an HTTP Archive file that contains a record of all the network requests that are made when a page is loaded.
It contains information about the request and response headers, cookies, content, timings, and more.
You can use HAR files to mock network requests in your tests. HAR will be saved to output/har.
More info could be found here https://playwright.dev/docs/api/class-browser#browser-new-context-option-record-har.
...
recordHar: {
mode: 'minimal', // possible values: 'minimal'|'full'.
content: 'embed' // possible values: "omit"|"embed"|"attach".
}
...
await I.amOnPage('/form/select');
await I.selectOption('Select your age', '21-');
🐛 Bug Fixes
Emit the new event: event.workers.result.
CodeceptJS also exposes the env var `process.env.RUNS_WITH_WORKERS` when running tests with run-workers command so that you could handle the events better in your plugins/helpers.
const { event } = require('codeceptjs');
module.exports = function() {
// this event would trigger the `_publishResultsToTestrail` when running `run-workers` command
event.dispatcher.on(event.workers.result, async () => {
await _publishResultsToTestrail();
});
// this event would not trigger the `_publishResultsToTestrail` multiple times when running `run-workers` command
event.dispatcher.on(event.all.result, async () => {
// when running `run` command, this env var is undefined
if (!process.env.RUNS_WITH_WORKERS) await _publishResultsToTestrail();
});
}
replaced minify library with a modern and more secure fork. Fixes html-minifier@4.0.0 Regular Expression Denial of Service vulnerability #3829
AI class is implemented as singleton
refactored heal.js plugin to work on edge cases
add configuration params on number of fixes performed by ay heal
improved recorder class to add more verbose log
improved recorder class to ignore some of errors
Fixed this error:
locator.isVisible: Unexpected token "s" while parsing selector ":has-text('Were you able to resolve the resident's issue?') >> nth=0"
at Playwright.waitForText (node_modules\codeceptjs\lib\helper\Playwright.js:2584:79)
Currently inside the _before() of helpers for example Playwright, the retries is set there, however, when retryFailedStep plugin is enabled, the retries of recorder is still using the value from _before() not the value from retryFailedStep plugin.
Fix:
- introduce the process.env.FAILED_STEP_RETIRES which could be access everywhere as the helper won't know anything about the plugin.
- set default retries of Playwright to 3 to be on the same page with Puppeteer.
When test title doesn't have the data in examples:
Feature: Faker examples
Scenario Outline: Below are the users
Examples:
| user | role |
| John | admin |
| Tim | client |
Faker examples --
[1] Starting recording promises
Timeouts:
Below are the users {"user":"John","role":"admin"}
✔ OK in 4ms
Below are the users {"user":"Tim","role":"client"}
✔ OK in 1ms
When test title includes the data in examples:
Feature: Faker examples
Scenario Outline: Below are the users - <user> - <role>
Examples:
| user | role |
| John | admin |
| Tim | client |
Faker examples --
[1] Starting recording promises
Timeouts:
Below are the users - John - admin
✔ OK in 4ms
Below are the users - Tim - client
✔ OK in 1ms
📖 Documentation
Changelog
3.5.8
Thanks all to those who contributed to make this release!
🐛 Bug Fixes fix(appium): type of setNetworkConnection() (#3994) - by @mirao fix: improve the way to show deprecated appium v1 message (#3992) - by @KobeNguyenT fix: missing exit condition of some wait functions - by @KobeNguyenT
Changelog
3.5.7
Thanks all to those who contributed to make this release!
🐛 Bug Fixes
npx playwright install
to install the browsers as starting from 1.39.0 browsers are not installed automatically (#3924) - by @KobeNguyenTFunktionalität: Faker examples
Szenariogrundriss: Atualizar senha do usuário
Angenommen que estou logado via REST com o usuário "<customer>"
| protocol | https: |
| hostname | https://cucumber.io/docs/gherkin/languages/ |
Faker examples --
Atualizar senha do usuário {"product":"{{vehicle.vehicle}}","customer":"Dr. {{name.findName}}","price":"{{commerce.price}}","cashier":"cashier 2"}
On Angenommen: que estou logado via rest com o usuário "dr. {{name.find name}}"
protocol | https:
hostname | https://cucumber.io/docs/gherkin/languages/
Dr. {{name.findName}}
✔ OK in 13ms
Renamed haveRequestHeaders of Puppeteer, Playwright helper so that it would not confuse the REST helper.
Puppeteer: setPuppeteerRequestHeaders
Playwright: setPlaywrightRequestHeaders
With this fix, we could now use the following syntax:
export = new Factory()
.attr('name', () => faker.name.findName())
.attr('job', () => 'leader');
export default new Factory()
.attr('name', () => faker.name.findName())
.attr('job', () => 'leader');
modules.export = new Factory()
.attr('name', () => faker.name.findName())
.attr('job', () => 'leader');
📖 Documentation
🛩️ Features
[Trace Recording Customization]
Trace recording provides complete information on test execution and includes screenshots, and network requests logged during run. Traces will be saved to output/trace
trace: enables trace recording for failed tests; trace are saved into output/trace folder
keepTraceForPassedTests: - save trace for passed tests
* This helper allows performing assertions based on Chai.
*
* ### Examples
*
* Zero-configuration when paired with other helpers like REST, Playwright:
*
* ```js
* // inside codecept.conf.js
*{
* helpers: {
* Playwright: {...},
* ExpectHelper: {},
* }
Expect Helper
#expectEqual
#expectNotEqual
#expectContain
#expectNotContain
#expectStartsWith
#expectNotStartsWith
#expectEndsWith
#expectNotEndsWith
#expectJsonSchema
#expectHasProperty
#expectHasAProperty
#expectToBeA
#expectToBeAn
#expectMatchRegex
#expectLengthOf
#expectTrue
#expectEmpty
#expectFalse
#expectAbove
#expectBelow
#expectLengthAboveThan
#expectLengthBelowThan
#expectLengthBelowThan
#expectDeepMembers
#expectDeepIncludeMembers
#expectDeepEqualExcluding
#expectLengthBelowThan
- grabCheckedElementStatus
- grabDisabledElementStatus
#language: de
Funktionalität: Checkout-Prozess
Um Produkte zu kaufen
Als Kunde
Möchte ich in der Lage sein, mehrere Produkte zu kaufen
@i18n
Szenariogrundriss: Bestellrabatt
Angenommen ich habe ein Produkt mit einem Preis von <price>$ in meinem Warenkorb
Und der Rabatt für Bestellungen über $20 beträgt 10 %
Wenn ich zur Kasse gehe
Dann sollte ich den Gesamtpreis von "<total>" $ sehen
Beispiele:
| price | total |
| 10 | 10.0 |
Instead of asserting on page elements for the current user in check, you can use the session you saved in fetch
autoLogin: {
enabled: true,
saveToFile: true,
inject: 'login',
users: {
admin: {
login: async (I) => { // If you use async function in the autoLogin plugin
const phrase = await I.grabTextFrom('#phrase')
I.fillField('username', 'admin'),
I.fillField('password', 'password')
I.fillField('phrase', phrase)
},
check: (I, session) => {
// Throwing an error in `check` will make CodeceptJS perform the login step for the user
if (session.profile.email !== the.email.you.expect@some-mail.com) {
throw new Error ('Wrong user signed in');
}
},
}
}
}
Scenario('login', async ( {I, login} ) => {
await login('admin') // you should use `await`
})
Changelog
3.5.6
Thanks all to those who contributed to make this release!
🐛 Bug Fixes
verbose/ highlight TRUE TRUE -> highlight element
verbose/ highlight TRUE FALSE -> no highlight element
verbose/ highlight FALSE TRUE -> no highlight element
verbose/ highlight FALSE FALSE -> no highlight element
const accounts = new DataTable(['role', 'username', 'password']);
accounts.add([
'ROLE_A',
process.env['FIRST_USERNAME'],
secret(process.env['FIRST_PASSWORD']),
]);
accounts.add([
'ROLE_B',
process.env['SECOND_USERNAME'],
secret(process.env['SECOND_PASSWORD']),
]);
Data(accounts)
.Scenario(
'ScenarioTitle',
({ I, pageObject, current }) => {
I.say("Given I'am logged in");
I.amOnPage('/');
loginPage.**sendForm**(current.username, current.password);
)
// output
The test feature --
The scenario | {"username":"Username","password": ***}
'The real password: theLoggedPasswordInCleartext'
I.fillField('somePasswordLocator', '****')
✔ OK in 7ms
The scenario | {"username":"theSecondUsername","password": ***}
'The real password: theLoggedPasswordInCleartext'
I.fillField('somePasswordLocator', '****')
✔ OK in 1ms
📖 Documentation
🛩️ Features
- Add some french keywords for translation
- I.waitForClickable has the same "attends" than I.wait. Using "attends" leads to use the deprecated waitForClickable. Fix it by using different words.