Hello, I have a situation in my project, where I need to perform couple of actions using I object in the browser window in the after.test.event. Example: Delete a data from UI once the test execution is complete.
I am using promise-based approach.
What do you get instead?
There appears to be a race condition occurring when the event.test.after and the After event, in which the browser is closed, does not wait for the steps to complete under event.test.passed.
Provide console output if related. Use --verbose mode for more details.
# paste output here
Test something --
[1] Starting recording promises
Timeouts:
test scenario @delete
I am on page "https://www.google.com/"
Test Passed
√ OK in 3498ms
I grab current url
Test Complete
» [Url] https://www.google.com/
Url is https://www.google.com/
I fill field {"id":"APjFqb"}, "testttt"
[1] Error | TypeError: elemResponse.map is not a function
[1] Error | TypeError: elemResponse.map is not a function
× "after all" hook: codeceptjs.afterSuite for "test scenario @delete" in 18ms
[1] Error | TypeError: elemResponse.map is not a function
TypeError: elemResponse.map is not a function
-- FAILURES:
1) Test something
"after all" hook: codeceptjs.afterSuite for "test scenario @delete":
elemResponse.map is not a function
at Browser.getElements (node_modules\webdriverio\build\utils\getElementObject.js:53:35)
at Browser.$$ (node_modules\webdriverio\build\commands\browser\$$.js:7:59)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Browser.wrapCommandFn (node_modules\@wdio\utils\build\shim.js:63:29)
at async WebDriver._locate (node_modules\codeceptjs\lib\helper\WebDriver.js:801:19)
at async WebDriver.fillField (node_modules\codeceptjs\lib\helper\WebDriver.js:1024:17)
Provide test source code if related
For any test scenario, set `restart: true` for the helper. Just have these hooks executed
Feature('Test something');
Scenario('test scenario', async ({ I }) => {
await I.amOnPage('https://www.google.com/');
});
********************Event Dispatcher*************
event.dispatcher.on(event.test.passed, async function () {
const {I} = inject();
console.log("Test Passed");
console.log(`Url is ${await I.grabCurrentUrl()}`);
await I.fillField({id: 'APjFqb'}, 'testttt');
});
event.dispatcher.on(event.test.after, async function () {
console.log("Test Complete");
});
Details
CodeceptJS version: 3.4.1
NodeJS Version: 20.5.1
Operating System: Mac/Windows
puppeteer || webdriverio || testcafe version (if related): Webdriverio
What are you trying to achieve?
Hello, I have a situation in my project, where I need to perform couple of actions using
I
object in the browser window in theafter.test.event
. Example: Delete a data from UI once the test execution is complete.I am using promise-based approach.
What do you get instead?
There appears to be a race condition occurring when the
event.test.after
and theAfter
event, in which the browser is closed, does not wait for the steps to complete underevent.test.passed
.Details