public string ProvideBrowserDriver() { _logger.Debug("Checking browser driver."); string fullDriverPath = _customDriverManager.ConstructFullDriverPath(); bool canAutoResolveVersion = CanAutoResolveVersion(); // Check whether browser file exists. if (File.Exists(fullDriverPath)) { // If it is exist, check whether we can resolve it version or not. if (!canAutoResolveVersion) { _logger.Info("Browser driver installed, cannot check version, update will be skipped."); return(fullDriverPath); } // If we can autoupdate it, check whether we should update it or not. if (ChromeVersionChecker.DoesDriverVersionEqualToBrowser(fullDriverPath)) { _logger.Info("Appropriate browser driver installed, update is not required."); return(fullDriverPath); } _logger.Info("Browser driver must be updated."); } else { _logger.Info("Browser driver is not installed."); } // Install or update driver. return(AutoInstallOrUpdateDriver(canAutoResolveVersion)); }
private SongRequestResult ProcessResult(SongRequestModel songRequest) { if (!_settings.ShouldParseResult) { _logger.Info("No need to parse result. Returning success."); return(SongRequestResult.Success(songRequest, _settings.DefaultSuccessMessage)); } _logger.Info( $"Song request '{songRequest.RequestId.ToString()}' seems to be added, " + "processing result." ); // Page can be loaded to quickly, need that notification will be enabled. var waiter = new WebDriverWait(_webDriver, TimeoutToWait); var notification = waiter.Until( driver => driver.FindElement(By.ClassName(_settings.ClassNameOfNotificationIcon)) ); _logger.Debug("Found notification icon."); var success = notification.FindElements( By.ClassName(_settings.ClassNameOfSuccessNotificationIcon) ); _logger.Debug("Tried to find success notification icon."); var failure = notification.FindElements( By.ClassName(_settings.ClassNameOfErrorNotificationIcon) ); _logger.Debug("Tried to find error notification icon."); var description = _webDriver.FindElement( By.ClassName(_settings.ClassNameOfNotificationDescription) ); var descriptionText = description.Text; _logger.Debug($"Found notification description: [{descriptionText}]."); // Success. if (success.Count > 0 && failure.Count == 0) { _logger.Info( $"Song request '{songRequest.RequestId.ToString()}' processed successfully. " + $"Result: {descriptionText}" ); return(SongRequestResult.Success(songRequest, descriptionText)); } // Failure. _logger.Info( $"Song request {songRequest.RequestId.ToString()} processed with failure. " + $"Error: {descriptionText}" ); return(SongRequestResult.Fail(songRequest, descriptionText)); }