示例#1
0
        public IBrowserCommandExecutor CreateBrowserCommandExecutor(string applicationPath, HtmlPage page)
        {
            var browserEmulator = new BrowserEmulator(applicationPath);

            // set time out to zero, to limit find elemenet attempts to 1
            HtmlElementCollection.FindElementTimeout = 0;

            return browserEmulator.CreateCommandExecutor();
        }
        /// <summary>
        /// ctor
        /// </summary>
        /// <param name="emulator">reference BrowserEmulator</param>
        internal EmulatedBrowserCommandExecutor(BrowserEmulator emulator)
        {
            this._emulator = emulator;

            // register all browser command handlers
            _browserCommandHandlerFactory = new Dictionary <string, BrowserCommandHandler>();
            RegisterBrowserCommandHandler(BrowserCommand.FunctionNames.NavigateToUrl, ExecuteCommandNavigateToUrl);
            RegisterBrowserCommandHandler(BrowserCommand.FunctionNames.GetPageDom, ExecuteCommandGetPageDom);
            RegisterBrowserCommandHandler(BrowserCommand.FunctionNames.SetTextBox, ExecuteCommandSetText);
            RegisterBrowserCommandHandler(BrowserCommand.FunctionNames.ClickElement, ExecuteClickElement);
            RegisterBrowserCommandHandler(BrowserCommand.FunctionNames.GetElementInnerHtml, ExecuteCommandGetElementInnerHtml);
            RegisterBrowserCommandHandler(BrowserCommand.FunctionNames.GetElementDom, ExecuteCommandGetElementDom);
            RegisterBrowserCommandHandler(BrowserCommand.FunctionNames.FormSubmit, ExecuteFormSubmit);
            RegisterBrowserCommandHandler(BrowserCommand.FunctionNames.SetSelectBoxIndex, ExecuteCommandSetSelectBoxIndex);
            RegisterBrowserCommandHandler(BrowserCommand.FunctionNames.GetElementInnerText, ExecuteCommandGetElementInnerText);
            RegisterBrowserCommandHandler(BrowserCommand.FunctionNames.GetElementInnerTextRecursive, ExecuteCommandGetElementInnerTextRecursive);
            RegisterBrowserCommandHandler(BrowserCommand.FunctionNames.GetElementAttributes, ExecuteCommandGetElementAttributes);
        }