public void Back() { if (CurrentBrowser.CanGoBack) { CurrentBrowser.Back(); } }
protected virtual void InvokeScriptFunction(string functionName, params object[] argsJsonStr) { CurrentBrowser.Invoke(new Action(() => { Document.InvokeScript(functionName, argsJsonStr); })); }
public void Forward() { if (CurrentBrowser.CanGoForward) { CurrentBrowser.Forward(); } }
public void PrintToPdfAsync(string path) { var printToPdf = CurrentBrowser.PrintToPdfAsync(path); printToPdf.ContinueWith(_ => { Context.DispatchEvent(WebViewEvent.OnPdfPrinted, ""); }, TaskContinuationOptions.OnlyOnRanToCompletion); }
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); } }
public void Load(string url) { if (_isLoaded) { CurrentBrowser.Load(url); } else { InitialUrl = url; } }
public void Load(UrlRequest url, string allowingReadAccessTo = null) { if (_isLoaded) { CurrentBrowser.Load(url.Url); } else { InitialUrl = url; } }
public void LoadHtmlString(string html, UrlRequest url) { if (_isLoaded) { CurrentBrowser.LoadHtml(html, url.Url); } else { _initialHtml = html; InitialUrl = url; } }
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()); }
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); }
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)); } }
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); } }
public void CloseDevTools() { CurrentBrowser.CloseDevTools(); }
public void ShowDevTools() { CurrentBrowser.ShowDevTools(); }
protected virtual void InvokeScriptFunction(Action action) { CurrentBrowser.Invoke(action); }
public void Print() { CurrentBrowser.Print(); }
protected virtual void InvokeWindow(Action action) { CurrentBrowser.FindForm()?.Invoke(action); }
public void CleanUpTest() { TestLogger.Info(Resources.StrTestResaults); TestLogger.Info(TestContext.TestName + " : " + TestContext.CurrentTestOutcome); CurrentBrowser.Quit(); }
public void Reload(bool ignoreCache) { CurrentBrowser.Reload(ignoreCache); }
public void ForceFocus() { CurrentBrowser.Focus(); }
public void NavigateTo(string url) { CurrentBrowser.StopLoad(); CurrentBrowser.GetMainFrame().LoadUrl(url); }
public void FullPageScreenshot() { CurrentBrowser.GenerateFullpageScreenshot(); }
private void OnPermissionPopup(object sender, string s) { CurrentBrowser.Load(s); }
public void Stop() { CurrentBrowser.Stop(); }
public void CurrentViewScreenshot() { CurrentBrowser.GetCurrentViewportScreenshot(); }