简体   繁体   中英

Error: function timed out, ensure the promise resolves within - Cucumber js

I am using protractor with cucumber js i have all function with async and await and also set global timeout

var {setDefaultTimeout} = require('cucumber'); setDefaultTimeout(60 * 1000);

Then('I click on tab', async ()=> {
  
    await organizationOperation.clickHeaderTab();

  });

Question - if i use wrong xpath/element is not located in UI, in that case getting below error

Error: function timed out, ensure the promise resolves within 60000 milliseconds

It should throw an error locator not found (locator text)

or if directly i use

  Then('I click on tab', async ()=> {
      
 const d = await $('.xxxxx').getText();
     console.log(d)

});

getting same error --> Error: function timed out, ensure the promise resolves within 30000 milliseconds

Why it is not showing - element not found error on console..?

Are you using implicit wait in your code while launching a browser? If Yes, make sure your timeout is more than implicit wait time you provided.. If not, declare implicit wait time with less than the default setDefaultTimeout(60 * 1000);

In case implicit wait is more than default time, we used to get this error function timed out, make sure to resolve with in ****. In case implicit wait is less than the default time, waiting for an element via implicit wait will expire first and throws Element Not Found exception.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM