public CSharpToJavascriptConverter(IWebBrowserWindow context, IJavascriptSessionCache cacher, IJSCommandFactory commandFactory, IWebSessionLogger logger) { _Context = context; _CommandFactory = commandFactory; _Logger = logger; _Cacher = cacher; }
/// <summary> /// Opens a new browser window /// <para>Note: If changing browser types, all windows opened by the previous type must be closed first</para> /// </summary> /// <param name="url">The URL for the window to navigate to</param> /// <param name="webBrowserType">The type of browser to open (e.g. "IE", "Chrome", "Firefox", "Safari")</param> /// <param name="closeAllOtherBrowserWindows">If true, all browsers of type webBrowserType will be closed before opening the new window</param> /// <param name="maximizeWindow">If true, the new window will be maximized if not already</param> public static BrowserWindow Open(string url, string webBrowserType, bool closeAllOtherBrowserWindows = true, bool maximizeWindow = true) { WebBrowserType browserType = ParseBrowserType(webBrowserType); InitializeAgent(browserType); if (closeAllOtherBrowserWindows) { Agent.CloseAllBrowserWindows(); } IWebBrowserWindow _browser = Agent.OpenNewBrowser(url); if (maximizeWindow) { _browser.MaximizeBrowserWindow(); } //hackhack: below waitForDocumentReadyState occasionally raise exception, so catch it then retry to open the browser try { _browser.WaitForDocumentReadyState(); } catch (WebOperationFailedException) { Agent.CloseAllBrowserWindows(); _browser = Agent.OpenNewBrowser(url); _browser.WaitForDocumentReadyState(); } //Logger.Instance.LogInfo("Opening a browser window, url: " + url + ", browser type: " + webBrowserType); //Historian.AddVisistedUrl(url); return(new BrowserWindow(_browser)); }
/// <summary> /// Unattaches the window from the framework agent and subsequently reattaches it /// <para>Users can input the amount of waiting time they want (unit: ms)</para> /// </summary> public void RefreshAttachmentToAgent(int waitTime = TabSleep) { IntPtr handle = TfsBrowserWindow.WindowHandle; TfsBrowserWindow.Unattach(); System.Threading.Thread.Sleep(waitTime); // Random wait. Without it this method didn't seem to work cross-browser. TfsBrowserWindow = Agent.AttachToExistingBrowserWindow(handle); }
public HtmlViewContext(IWebBrowserWindow webBrowserWindow, IUiDispatcher uiDispatcher, IJavascriptFrameworkManager javascriptFrameworkManager, IWebSessionLogger logger) { _IWebBrowserWindow = webBrowserWindow; Logger = logger; UiDispatcher = uiDispatcher; _JavascriptFrameworkManager = javascriptFrameworkManager; }
public static WebBrowserWindowDimensions GetDimensions(this IWebBrowserWindow browser) { var width = browser.ExecuteJScript <int>("return window.outerWidth;"); var height = browser.ExecuteJScript <int>("return window.outerHeight;"); return(new WebBrowserWindowDimensions { OuterHeight = height, OuterWidth = width }); }
public HTMLViewContext(IWebBrowserWindow webBrowserWindow, IDispatcher uiDispatcher, IJavascriptFrameworkManager javascriptFrameworkManager, IJavascriptChangesObserver javascriptChangesObserver, IWebSessionLogger logger) { _IWebBrowserWindow = webBrowserWindow; _logger = logger; UIDispatcher = uiDispatcher; _JavascriptChangesObserver = javascriptChangesObserver; _JavascriptFrameworkManager = javascriptFrameworkManager; }
public CSharpToJavascriptConverterTests() { _Cacher = Substitute.For <IJavascriptSessionCache>(); _Cacher.When(c => c.CacheFromCSharpValue(Arg.Any <object>(), Arg.Any <IJSCSGlue>())) .Do(callInfo => _Cache.Add(callInfo[0], (IJSCSGlue)callInfo[1])); _Cacher.GetCached(Arg.Any <object>()).Returns(callInfo => _Cache.GetOrDefault(callInfo[0])); _GlueFactory = new GlueFactory(null, null); _Logger = Substitute.For <IWebSessionLogger>(); _IWebBrowserWindow = Substitute.For <IWebBrowserWindow>(); _IWebBrowserWindow.IsTypeBasic(typeof(string)).Returns(true); _CSharpToJavascriptConverter = new CSharpToJavascriptConverter(_IWebBrowserWindow, _Cacher, _GlueFactory, _Logger); }
/// <summary> /// Close the browser window /// </summary> public void Close() { try { if (TfsBrowserWindow != null) { TfsBrowserWindow.CloseBrowserWindow(); } } catch { WindowHelper.CloseWindow(TfsBrowserWindow.WindowHandle); } finally { TfsBrowserWindow = null; } }
/// <summary> /// Find a browser window by title of the same browser type as this object /// </summary> /// <param name="possibleWindowTitles">An array of the possible browser window titles to look for</param> /// <param name="ignorePreviouslyAttachedWindows">If true, ignore any windows that have previously been attached to by the framework</param> /// <param name="isModal"> /// Whether or not the window to attach to is modal, meaning a child window that requires user interaction /// before being able to return to operating the parent window /// </param> /// <param name="timeoutMs">The duration in milliseconds to try to find the popup window</param> /// <returns>The reference to the browser window</returns> public BrowserWindow FindPopupBrowserWindow(string[] possibleWindowTitles, bool ignorePreviouslyAttachedWindows = true, bool isModal = false, int timeoutMs = 5000) { int originalTimeout = TfsBrowserWindow.FrameworkAgent.FindBrowserWindowTimeout; TfsBrowserWindow.FrameworkAgent.FindBrowserWindowTimeout = timeoutMs; try { IWebBrowserWindow popup = (possibleWindowTitles.Length == 1) ? TfsBrowserWindow.GetPopupWindow(possibleWindowTitles[0], isModal, ignorePreviouslyAttachedWindows) : TfsBrowserWindow.GetPopupWindow(possibleWindowTitles, isModal, ignorePreviouslyAttachedWindows); return(new BrowserWindow(popup)); } catch (Exception e) { throw e; } finally { TfsBrowserWindow.FrameworkAgent.FindBrowserWindowTimeout = originalTimeout; } }
internal AwesomiumTestHTMLWindowProvider(IWebView webView, Uri path) { HTMLWindow = new AwesomiumTestHTMLWindow(webView, path); }
public ChromiumFXHTMLWindowProvider(CfxClient cfxClient, IWebView webview, Uri url) { _Webview = webview; _CfxClient = cfxClient; HtmlWindow = new FakeHTMLWindow(cfxClient, webview, url); }
public TestCefGlueHTMLWindowProvider(CefFrame iFrame, TestCefClient cefClient) { _TestCefClient = cefClient; HtmlWindow = new TestCefGlueWindow(iFrame, cefClient); }
public TestCefGlueHTMLWindowProvider(CefFrame iFrame, TestCefClient cefClient) { _TestCefClient = cefClient; HTMLWindow = new TestCefGlueWindow(iFrame, cefClient); }
/// <param name="booleanExpression">Ex. foo == true</param> public static void WaitOnJScriptExpressionTrue(this IWebBrowserWindow browser, string booleanExpression) { browser.WaitOnJScriptExpression(60, string.Format("return {0};", booleanExpression), "true"); }
public ChromiumFXHTMLWindowProvider(CfxClient cfxClient, IWebView webview, Uri url) { _webview = webview; _CfxClient = cfxClient; HTMLWindow = new FakeHTMLWindow(cfxClient, webview, url); }
public static T ExecuteJScript <T>(this IWebBrowserWindow browser, string script) { var result = browser.ExecuteJScript(script); return((T)Convert.ChangeType(result, typeof(T))); }
/// <summary> /// Create a BrowserWindow by using the static method Open /// </summary> private BrowserWindow(IWebBrowserWindow browser) { TfsBrowserWindow = browser; }
public FirstLoadEvent(IWebBrowserWindow window) { Window = window; }