Open garg3133 opened 8 months ago
I am looking into this issue
@garg3133 Can I get the full script so I can test it locally?
You can use this example test to reproduce this:
describe('ecosia demo', function() {
before(() => {
browser
.navigateTo('https://ecosia.org/');
});
it('waitUntil callback demo', function() {
browser
.waitUntil(async function() {
const title = await browser.getTitle();
console.log(title); // <-- returns NightwatchAPI
return true;
})
.perform(async function() {
const title = await browser.getTitle();
console.log(title); // <-- returns correct result (title)
});
});
});
@garg3133 I was able to reproduce the problem. Thanks.
Here is an update: I have regressed to previous versions of Nightwatchjs, all the way back to 3.1.0, and I get the same error. It appears waitUntil
never really worked as expected 🤔
Yeah, it didn't for this particular case. But if you change the line it('waitUntil callback demo', function() {
to it('waitUntil callback demo', async function() {
in the example test (notice the added async
before function definition), it will work correctly.
Yeah, it didn't for this particular case. But if you change the line
it('waitUntil callback demo', function() {
toit('waitUntil callback demo', async function() {
in the example test (notice the addedasync
before function definition), it will work correctly.
Exactly, I just observed that.
As a contrast, in the perform
function, I removed async/await
and made it non-async
and I get the same error. That is, the Nightwatch API.
I am woking on this issue and was able to reproduce it. Looking forward to solve it .
Another issue I've found with
waitUntil
is that if we pass an async callback towaitUntil
command, Nightwatch commands inside the callback still just returnNightwatchAPI
and no promise which can be awaited to get the result. While inperform
command, it works fine and Nightwatch commands return a promise insideasync
callback passed toperfom
command.All this is when we do not use
async
in the test case function.Edit: This problem goes away if we set
always_async_commands
top-level setting totrue
in the Nightwatch config file.To reproduce:
This issue can be reproduced by running the following example test:
Previous conversation regarding this:
Issue created from https://github.com/nightwatchjs/nightwatch/issues/3511#issuecomment-1365243803