Beispiel #1
0
        public static IHttpWebScrapper Create(
            ISongRequestScriptSettings settings,
            IScriptLogger logger)
        {
            logger.Info($"Creating web scrapper for driver '{settings.SelectedBrowserDriver.Value}'.");
            logger.Info($"WebDriver path: [{settings.BrowserDriverPath.Value}].");
            logger.Info($"WebDriver executable name: [{settings.BrowserDriverExecutableName.GetFullFilename()}].");

            var webDriver = CreateWebDriver(settings, logger);

            return(new HttpWebScrapper(settings, logger, webDriver));
        }
        internal HttpWebScrapper(
            ISongRequestScriptSettings settings,
            IScriptLogger logger,
            IWebDriver webDriver)
        {
            _settings  = settings ?? throw new ArgumentNullException(nameof(settings));
            _logger    = logger ?? throw new ArgumentNullException(nameof(logger));
            _webDriver = webDriver ?? throw new ArgumentNullException(nameof(webDriver));

            _newSongTextFieldLazy  = new Lazy <IWebElement>(() => FindNewSongTextField());
            _addSongButtonLazy     = new Lazy <IWebElement>(() => FindAddSongButton());
            _skipSongButtonLazy    = new Lazy <IWebElement>(() => FindSkipSongButton());
            _removeQueueButtonLazy = new Lazy <IWebElement>(() => FindRemoveQueueSongButton());
        }
Beispiel #3
0
        public static DriverProvider Create(
            ISongRequestScriptSettings settings,
            IScriptLogger logger,
            Architecture architecture = Architecture.Auto)
        {
            return(settings.SelectedBrowserDriver.Value switch
            {
                WebDriverType.RawEdgeDriver => CreateForEdge(settings, logger, architecture),

                WebDriverType.RawChromeDriver => CreateForChrome(settings, logger, architecture),

                WebDriverType.RawFirefoxDriver => CreateForFirefox(settings, logger, architecture),

                WebDriverType.RawOperaDriver => CreateForOpera(settings, logger, architecture),

                _ => throw new ArgumentOutOfRangeException(
                    nameof(settings.SelectedBrowserDriver),
                    settings.SelectedBrowserDriver,
                    $"Unexpected webdriver type value: '{settings.SelectedBrowserDriver.Value}'."
                    )
            });
Beispiel #4
0
        private static IWebDriver CreateWebDriver(
            ISongRequestScriptSettings settings,
            IScriptLogger logger)
        {
            EnsureBrowserDriverIsInstalled(settings, logger);

            return(settings.SelectedBrowserDriver.Value switch
            {
                WebDriverType.RawEdgeDriver => CreateEdgeDriver(settings),

                WebDriverType.RawChromeDriver => CreateChromeDriver(settings),

                WebDriverType.RawFirefoxDriver => CreateFirefoxDriver(settings),

                WebDriverType.RawOperaDriver => CreateOperaDriver(settings),

                _ => throw new ArgumentOutOfRangeException(
                    nameof(settings.SelectedBrowserDriver),
                    settings.SelectedBrowserDriver,
                    $"Unexpected webdriver type value: '{settings.SelectedBrowserDriver.Value}'."
                    )
            });