コード例 #1
0
        public IBrowserProcess Create(string urlToOpen)
        {
            var browserPathsToRun = new StructList <string>();
            var headlessOverride  = Environment.GetEnvironmentVariable("BBBROWSER");

            if (headlessOverride != null)
            {
                browserPathsToRun.AddUnique(headlessOverride);
            }

            if (!_fsAbstraction.IsUnixFs && _strategy == "PreferFirefoxOnWindows")
            {
                var browserPath = BrowserPathFinder.GetBrowserPath(_fsAbstraction, true);
                if (browserPath != null)
                {
                    browserPathsToRun.AddUnique(browserPath);
                }
            }

            if (browserPathsToRun.Count == 0)
            {
                var browserPath = BrowserPathFinder.GetBrowserPath(_fsAbstraction, false);
                if (browserPath != null)
                {
                    browserPathsToRun.AddUnique(browserPath);
                }
            }

            if (browserPathsToRun.Count == 0)
            {
                throw new Exception("Cannot find browser on common known paths, use BBBROWSER environmental variable to define path to browser.");
            }

            return(new BrowserProcessFactory(_inDocker, browserPathsToRun[0]).Create(urlToOpen));
        }