Skip to content

Remove redundant dependencies from ElementFinder #31 #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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