Skip to content

Commit

Permalink
Remove redundant dependencies from ElementFinder #31 (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
paveliam authored and knysh committed Dec 9, 2019
1 parent 3b4c2a1 commit 46d617c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,16 @@ public void ConfigureServices(IServiceCollection services, Func<IServiceProvider
settingsFile = settings ?? GetSettings();
services.AddScoped(applicationProvider);

services.AddSingleton<ITimeoutConfiguration>(new TimeoutConfiguration(settingsFile));
services.AddTransient<ConditionalWait>();
services.AddSingleton<ILoggerConfiguration>(new LoggerConfiguration(settingsFile));
services.AddSingleton(settingsFile);
services.AddSingleton(Logger.Instance);
services.AddSingleton<ILoggerConfiguration, LoggerConfiguration>();
services.AddSingleton<ITimeoutConfiguration, TimeoutConfiguration>();
services.AddSingleton<IRetryConfiguration, RetryConfiguration>();
services.AddSingleton<ILocalizationManager, LocalizationManager>();
services.AddSingleton<ILocalizedLogger, LocalizedLogger>();
services.AddSingleton<IRetryConfiguration>(new RetryConfiguration(settingsFile));
services.AddSingleton<ElementActionRetrier>();

services.AddTransient<ConditionalWait>();
services.AddTransient<IElementFinder, ElementFinder>();
services.AddTransient<IElementFactory, ElementFactory>();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Aquality.Selenium.Core.Elements.Interfaces;
using Aquality.Selenium.Core.Localization;
using Aquality.Selenium.Core.Logging;
using Aquality.Selenium.Core.Waitings;
using OpenQA.Selenium;
using System;
Expand All @@ -15,19 +14,13 @@ namespace Aquality.Selenium.Core.Elements
/// </summary>
public class ElementFinder : IElementFinder
{
public ElementFinder(Logger logger, ILocalizedLogger localizedLogger, ILocalizationManager localizationManager, ConditionalWait conditionalWait)
public ElementFinder(ILocalizedLogger logger, ConditionalWait conditionalWait)
{
Logger = logger;
LocalizedLogger = localizedLogger;
LocalizationManager = localizationManager;
ConditionalWait = conditionalWait;
}

private Logger Logger { get; }

private ILocalizedLogger LocalizedLogger { get; }

private ILocalizationManager LocalizationManager { get; }
private ILocalizedLogger Logger { get; }

private ConditionalWait ConditionalWait { get; }

Expand Down Expand Up @@ -90,7 +83,7 @@ public ReadOnlyCollection<IWebElement> FindElements(By locator, DesiredState des

private void HandleTimeoutException(WebDriverTimeoutException ex, DesiredState desiredState, By locator, List<IWebElement> foundElements)
{
var message = LocalizationManager.GetLocalizedMessage("loc.no.elements.found.in.state", locator.ToString(), desiredState.StateName);
var message = $"No elements with locator '{locator.ToString()}' were found in {desiredState.StateName} state";
if (desiredState.IsCatchingTimeoutException)
{
if (!foundElements.Any())
Expand All @@ -99,11 +92,11 @@ private void HandleTimeoutException(WebDriverTimeoutException ex, DesiredState d
{
throw new NoSuchElementException(message);
}
Logger.Debug(message);
Logger.Debug("loc.no.elements.found.in.state", null, locator.ToString(), desiredState.StateName);
}
else
{
LocalizedLogger.Debug("loc.elements.were.found.but.not.in.state", null, locator.ToString(), desiredState.StateName);
Logger.Debug("loc.elements.were.found.but.not.in.state", null, locator.ToString(), desiredState.StateName);
}
}
else
Expand Down

0 comments on commit 46d617c

Please sign in to comment.