private async Task <ElementHandle> WaitForSelectorInUtilityContextAsync(string selector, WaitForOption waitFor, int?timeout) { var task = Dom.GetWaitForSelectorFunction(selector, waitFor, timeout); var result = await ScheduleRerunnableTaskAsync(task, ContextType.Utility, timeout, $"selector \"{SelectorToString(selector, waitFor)}\"").ConfigureAwait(false); if (!(result is ElementHandle)) { await result.DisposeAsync().ConfigureAwait(false); return(null); } return(result as ElementHandle); }