Modified waitForDialogToOpen