Exemple #1
0
 public void Back()
 {
     if (CurrentBrowser.CanGoBack)
     {
         CurrentBrowser.Back();
     }
 }
Exemple #2
0
 protected virtual void InvokeScriptFunction(string functionName, params object[] argsJsonStr)
 {
     CurrentBrowser.Invoke(new Action(() =>
     {
         Document.InvokeScript(functionName, argsJsonStr);
     }));
 }
Exemple #3
0
 public void Forward()
 {
     if (CurrentBrowser.CanGoForward)
     {
         CurrentBrowser.Forward();
     }
 }
Exemple #4
0
        public void PrintToPdfAsync(string path)
        {
            var printToPdf = CurrentBrowser.PrintToPdfAsync(path);

            printToPdf.ContinueWith(_ => { Context.DispatchEvent(WebViewEvent.OnPdfPrinted, ""); },
                                    TaskContinuationOptions.OnlyOnRanToCompletion);
        }
Exemple #5
0
 public void EvaluateJavaScript(string javascript)
 {
     try {
         var mf = CurrentBrowser.GetMainFrame();
         mf.ExecuteJavaScriptAsync(javascript); // this is fire and forget can run js urls, startLine
     }
     catch (Exception e) {
         Console.WriteLine(@"JS error: " + e.Message);
     }
 }
Exemple #6
0
 public void Load(string url)
 {
     if (_isLoaded)
     {
         CurrentBrowser.Load(url);
     }
     else
     {
         InitialUrl = url;
     }
 }
Exemple #7
0
 public void Load(UrlRequest url, string allowingReadAccessTo = null)
 {
     if (_isLoaded)
     {
         CurrentBrowser.Load(url.Url);
     }
     else
     {
         InitialUrl = url;
     }
 }
Exemple #8
0
 public void LoadHtmlString(string html, UrlRequest url)
 {
     if (_isLoaded)
     {
         CurrentBrowser.LoadHtml(html, url.Url);
     }
     else
     {
         _initialHtml = html;
         InitialUrl   = url;
     }
 }
Exemple #9
0
        public void TimedScreenshot(int seconds)
        {
            var future = DateTime.Now.AddSeconds(seconds);

            do
            {
                uiActionLoggedToolStripStatusLabel.Text = string.Format("Screenshotting in: {0}", (future - DateTime.Now).ToString("ss"));
                Application.DoEvents();
            } while (future > DateTime.Now);
            uiActionLoggedToolStripStatusLabel.Text = "";
            CurrentBrowser.GetCurrentViewportScreenshot();
        }
        public override Task <TaskResult> Process(TaskInfo task)
        {
            if (!(task is AddAuthHeaderTaskInfo))
            {
                throw new ArgumentException($"Expected AddHeaderTaskInfo but passed {task.GetType().Name}");
            }

            var result   = new TaskResult(false);
            var taskInfo = (AddAuthHeaderTaskInfo)task;

            CurrentBrowser.HeaderSetup.Authorization = taskInfo.HeaderValue;
            CurrentBrowser.SetHeader();
            return(result.Success());
        }
Exemple #11
0
        public void ZoomOut()
        {
            var task = CurrentBrowser.GetZoomLevelAsync();

            task.ContinueWith(previous => {
                if (previous.Status == TaskStatus.RanToCompletion)
                {
                    var currentLevel = previous.Result;
                    CurrentBrowser.SetZoomLevel(currentLevel - ZoomIncrement);
                }
                else
                {
                    throw new InvalidOperationException("Unexpected failure of calling CEF->GetZoomLevelAsync",
                                                        previous.Exception);
                }
            }, TaskContinuationOptions.ExecuteSynchronously);
        }
Exemple #12
0
        public async void EvaluateJavaScript(string javascript, string callback)
        {
            try {
                var mf       = CurrentBrowser.GetMainFrame();
                var response =
                    await mf.EvaluateScriptAsync(javascript, TimeSpan.FromMilliseconds(500).ToString());

                if (response.Success && response.Result is IJavascriptCallback javascriptCallback)
                {
                    response = await javascriptCallback.ExecuteAsync("");
                }

                Context.DispatchEvent(WebViewEvent.AsCallbackEvent, response.ToJsonString(callback));
            }
            catch (Exception e) {
                Context.DispatchEvent(WebViewEvent.AsCallbackEvent, e.ToJsonString(callback));
            }
        }
Exemple #13
0
        private void OnBrowserLoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
        {
            for (var index = 0; index < _tabs.Count; index++)
            {
                if (!_tabs[index].Equals(sender))
                {
                    continue;
                }
                var tabDetails = GetTabDetails(index);
                if (tabDetails.IsLoading == e.IsLoading)
                {
                    return;
                }

                tabDetails.IsLoading = e.IsLoading;
                SendPropertyChange(@"isLoading", e.IsLoading, index);
                if (!e.IsLoading)
                {
                    CurrentBrowser.Focus();
                }

                if (tabDetails.CanGoForward != e.CanGoForward)
                {
                    tabDetails.CanGoForward = e.CanGoForward;
                    SendPropertyChange(@"canGoForward", e.CanGoForward, index);
                }

                if (tabDetails.CanGoBack == e.CanGoBack)
                {
                    return;
                }

                tabDetails.CanGoBack = e.CanGoBack;
                SendPropertyChange(@"canGoBack", e.CanGoBack, index);
            }
        }
Exemple #14
0
 public void CloseDevTools()
 {
     CurrentBrowser.CloseDevTools();
 }
Exemple #15
0
 public void ShowDevTools()
 {
     CurrentBrowser.ShowDevTools();
 }
Exemple #16
0
 protected virtual void InvokeScriptFunction(Action action)
 {
     CurrentBrowser.Invoke(action);
 }
Exemple #17
0
 public void Print()
 {
     CurrentBrowser.Print();
 }
Exemple #18
0
 protected virtual void InvokeWindow(Action action)
 {
     CurrentBrowser.FindForm()?.Invoke(action);
 }
Exemple #19
0
 public void CleanUpTest()
 {
     TestLogger.Info(Resources.StrTestResaults);
     TestLogger.Info(TestContext.TestName + " : " + TestContext.CurrentTestOutcome);
     CurrentBrowser.Quit();
 }
Exemple #20
0
 public void Reload(bool ignoreCache)
 {
     CurrentBrowser.Reload(ignoreCache);
 }
Exemple #21
0
 public void ForceFocus()
 {
     CurrentBrowser.Focus();
 }
Exemple #22
0
 public void NavigateTo(string url)
 {
     CurrentBrowser.StopLoad();
     CurrentBrowser.GetMainFrame().LoadUrl(url);
 }
Exemple #23
0
 public void FullPageScreenshot()
 {
     CurrentBrowser.GenerateFullpageScreenshot();
 }
Exemple #24
0
 private void OnPermissionPopup(object sender, string s)
 {
     CurrentBrowser.Load(s);
 }
Exemple #25
0
 public void Stop()
 {
     CurrentBrowser.Stop();
 }
Exemple #26
0
 public void CurrentViewScreenshot()
 {
     CurrentBrowser.GetCurrentViewportScreenshot();
 }