コード例 #1
0
 public void TearDown()
 {
     Console.WriteLine("TearDown SystemTests");
     DevWebServer.Stop();
     BrowserApp.Stop();
     VstsSettings.RestoreWebConfig();
 }
コード例 #2
0
        /// <inheritdoc cref="IBrowserType.LaunchBrowserAppAsync(LaunchOptions)"/>
        public override async Task <IBrowserApp> LaunchBrowserAppAsync(LaunchOptions options = null)
        {
            options ??= new LaunchOptions();

            var(firefoxArguments, tempProfileDir) = PrepareFirefoxArgs(options);
            string     firefoxExecutable = GetBrowserExecutablePath(options);
            BrowserApp browserApp        = null;

            var process = new FirefoxProcessManager(
                firefoxExecutable,
                firefoxArguments,
                tempProfileDir,
                options.Timeout,
                async() =>
            {
                if (browserApp == null)
                {
                    return;
                }

                var transport = await BrowserHelper.CreateTransportAsync(browserApp.ConnectOptions).ConfigureAwait(false);
                await transport.SendAsync(new BrowserCloseRequest().Command).ConfigureAwait(false);
            },
                (exitCode) =>
            {
                browserApp?.ProcessKilled(exitCode);
            });

            try
            {
                SetEnvVariables(process.Process.StartInfo.Environment, options.Env, Environment.GetEnvironmentVariables());

                if (options.DumpIO)
                {
                    process.Process.ErrorDataReceived += (sender, e) => Console.Error.WriteLine(e.Data);
                }

                await process.StartAsync().ConfigureAwait(false);

                var connectOptions = new ConnectOptions()
                {
                    BrowserWSEndpoint = process.Endpoint,
                    SlowMo            = options.SlowMo,
                };

                return(new BrowserApp(process, () => Task.CompletedTask, connectOptions));
            }
            catch
            {
                await process.KillAsync().ConfigureAwait(false);

                throw;
            }
        }
コード例 #3
0
        /// <summary>
        /// Opens the specified browser type, to specified size, and location and to specified url.
        /// Returns the identifier of the browser instance
        /// </summary>
        public string Open_Browser(string browsertype, string browsersize, string location, string url)
        {
            var config = BrowserConfigLoader.GetConfig();

            config.Browsername     = (BrowserNames)Enum.Parse(typeof(BrowserNames), browsertype);
            config.Browsersize     = (BrowserSize)Enum.Parse(typeof(BrowserSize), browsersize);
            config.Browserlocation = (BrowserLocations)Enum.Parse(typeof(BrowserLocations), location);
            config.Url             = url;
            var browser = new BrowserApp(config);

            return(browser.Identifier);
        }
コード例 #4
0
        public void Start()
        {
            ManualResetEventSlim disposedEvent = new ManualResetEventSlim();

            dispatcher.Invoke(new Action(() =>
            {
                CefRuntime.Load();
                CefMainArgs cefMainArgs         = new CefMainArgs(IntPtr.Zero, new String[0]);
                BrowserRuntimeSettings settings = BrowserSettings.Instance.RuntimeSettings;

                isMultiThreadedMessageLoop = settings.MultiThreadedMessageLoop;

                CefSettings cefSettings = new CefSettings
                {
                    BrowserSubprocessPath   = @"plugins\CLRHostPlugin\CLRBrowserSourcePlugin\CLRBrowserSourcePipe.exe",
                    CachePath               = settings.CachePath,
                    CommandLineArgsDisabled = settings.CommandLineArgsDisabled,
                    IgnoreCertificateErrors = settings.IgnoreCertificateErrors,
                    JavaScriptFlags         = settings.JavaScriptFlags,
                    Locale                     = settings.Locale,
                    LocalesDirPath             = settings.LocalesDirPath,
                    LogFile                    = settings.LogFile,
                    LogSeverity                = settings.LogSeverity,
                    MultiThreadedMessageLoop   = settings.MultiThreadedMessageLoop,
                    PersistSessionCookies      = settings.PersistSessionCookies,
                    ProductVersion             = settings.ProductVersion,
                    ReleaseDCheckEnabled       = settings.ReleaseDCheckEnabled,
                    RemoteDebuggingPort        = settings.RemoteDebuggingPort,
                    ResourcesDirPath           = settings.ResourcesDirPath,
                    SingleProcess              = settings.SingleProcess,
                    UncaughtExceptionStackSize = settings.UncaughtExceptionStackSize
                };

                BrowserApp browserApp = new BrowserApp(settings.CommandLineArgsDisabled ? new String[0] : settings.CommandLineArguments);

                CefRuntime.ExecuteProcess(cefMainArgs, browserApp);
                CefRuntime.Initialize(cefMainArgs, cefSettings, browserApp);

                CefRuntime.RegisterSchemeHandlerFactory("local", null, new AssetSchemeHandlerFactory());
                CefRuntime.RegisterSchemeHandlerFactory("http", "absolute", new AssetSchemeHandlerFactory());
            }));

            PluginManager.Initialize();
        }
コード例 #5
0
        public void SetUp()
        {
            if (TestRegistry.TestHasFailed)
            {
                return; // no need to setup Selenium
            }
            Console.WriteLine("SetUp SystemTests");
            var runHeadless = RunHeadless();

            try
            {
                VstsSettings.UpdateWebConfig();
                DevWebServer.Start();
                BrowserApp.Start(runHeadless);
            }
            catch
            {
                TearDown();
                throw;
            }
        }
コード例 #6
0
        public void Start()
        {
            ManualResetEventSlim contextInitializedEvent =
                new ManualResetEventSlim();

            dispatcher.PostTask(new Action(() =>
            {
                CefRuntime.Load();
                CefMainArgs cefMainArgs         = new CefMainArgs(IntPtr.Zero, new String[0]);
                BrowserRuntimeSettings settings = BrowserSettings.Instance.RuntimeSettings;

                isMultiThreadedMessageLoop = settings.MultiThreadedMessageLoop;
                isSingleProcess            = BrowserSettings.Instance.RuntimeSettings.SingleProcess;

                string browserSubprocessPath = Path.Combine(AssemblyDirectory,
                                                            "CLRBrowserSourcePlugin", "CLRBrowserSourceClient.exe");

                CefSettings cefSettings = new CefSettings
                {
                    BrowserSubprocessPath   = browserSubprocessPath,
                    CachePath               = settings.CachePath,
                    CommandLineArgsDisabled = settings.CommandLineArgsDisabled,
                    IgnoreCertificateErrors = settings.IgnoreCertificateErrors,
                    JavaScriptFlags         = settings.JavaScriptFlags,
                    Locale                     = settings.Locale,
                    LocalesDirPath             = settings.LocalesDirPath,
                    LogFile                    = settings.LogFile,
                    LogSeverity                = settings.LogSeverity,
                    MultiThreadedMessageLoop   = settings.MultiThreadedMessageLoop,
                    NoSandbox                  = true,
                    PersistSessionCookies      = settings.PersistSessionCookies,
                    ProductVersion             = settings.ProductVersion,
                    RemoteDebuggingPort        = settings.RemoteDebuggingPort,
                    ResourcesDirPath           = settings.ResourcesDirPath,
                    SingleProcess              = false,
                    UncaughtExceptionStackSize = settings.UncaughtExceptionStackSize,
                    WindowlessRenderingEnabled = true
                };

                string[] commandLineArgs = settings.CommandLineArgsDisabled ?
                                           new String[0] : settings.CommandLineArguments;

                BrowserApp browserApp = new BrowserApp(
                    commandLineArgs, contextInitializedEvent);

                try
                {
                    CefRuntime.Initialize(cefMainArgs, cefSettings, browserApp, IntPtr.Zero);
                }
                catch (InvalidOperationException e)
                {
                    API.Instance.Log("Failed to initialize cef runtime");
                    contextInitializedEvent.Set();
                }

                CefRuntime.RegisterSchemeHandlerFactory("local", null, new AssetSchemeHandlerFactory());
                CefRuntime.RegisterSchemeHandlerFactory("http", "absolute", new AssetSchemeHandlerFactory());

                if (!settings.MultiThreadedMessageLoop)
                {
                    CefRuntime.RunMessageLoop();
                }
            }));

            contextInitializedEvent.Wait();
        }
 /// <inheritdoc />
 public void Dispose()
 {
     BrowserApp.CloseAsync().GetAwaiter().GetResult();
     BrowserApp = null;
     Browser    = null;
 }