Beispiel #1
0
        private async Task ExecuteScriptAsync(string script, Action <Task <JavascriptResponse> > continuation = null)
        {
            Task <JavascriptResponse> task;

            try
            {
                task = _browser.GetMainFrame().EvaluateScriptAsync(script, null, 1, TimeSpan.FromSeconds(60));
                await task.ConfigureAwait(false);

                if (continuation != null)
                {
                    var continueTask = task.ContinueWith(continuation);
                    await continueTask.ConfigureAwait(false);
                }
            }
            catch (TaskCanceledException)
            {
                throw new JavaScriptException("Не удалось выполнить скрипт за отведенное время.", script);
            }
        }