'Async await is not waiting for the cypress command to run

Using async await I would like to wait for some time before running the commands in cypress. But for some reason the below code is not waiting. Could someone please advise on the issue here ?

(async function doWaitForDialogOpen() {
  await new Promise(resolve => setTimeout(resolve, 4000));
   cy.get('#iframeID0').then(($iframe)=>{    
     Cypress.$($iframe).find('html').find('body').find('#someId').find('input').type(100);
   })
  await doWaitForDialogOpen();
 })();


Solution 1:[1]

Cypress has wait method, which will wait for given time. For more info here

Example:

(async function doWaitForDialogOpen() {
    await cy.wait(4000) // waits 4 seconds
    const $iframe = await cy.get('#iframeID0')
    Cypress.$($iframe)
   .find('html')
   .find('body')
   .find('#someId')
   .find('input')
   .type(100);
  // Do your next steps
 })();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1