Minor modification in waitForDialogToOpen()