diff --git a/Aquality.Selenium.Core/src/Aquality.Selenium.Core/Utilities/JsonSettingsFile.cs b/Aquality.Selenium.Core/src/Aquality.Selenium.Core/Utilities/JsonSettingsFile.cs index 5fbfcd2..21817db 100644 --- a/Aquality.Selenium.Core/src/Aquality.Selenium.Core/Utilities/JsonSettingsFile.cs +++ b/Aquality.Selenium.Core/src/Aquality.Selenium.Core/Utilities/JsonSettingsFile.cs @@ -68,7 +68,13 @@ public T GetValue(string path) var envValue = GetEnvironmentValue(path); if (envValue != null) { - return ConvertEnvVar(() => (T) TypeDescriptor.GetConverter(typeof(T)).ConvertFrom(envValue), + return ConvertEnvVar(() => + { + var type = typeof(T); + return type == typeof(object) + ? (T) Convert.ChangeType(envValue, type) + : (T) TypeDescriptor.GetConverter(type).ConvertFrom(envValue); + }, envValue, path); } diff --git a/Aquality.Selenium.Core/tests/Aquality.Selenium.Core.Tests/Utilities/JsonFileTests.cs b/Aquality.Selenium.Core/tests/Aquality.Selenium.Core.Tests/Utilities/JsonFileTests.cs index fc363d7..550404d 100644 --- a/Aquality.Selenium.Core/tests/Aquality.Selenium.Core.Tests/Utilities/JsonFileTests.cs +++ b/Aquality.Selenium.Core/tests/Aquality.Selenium.Core.Tests/Utilities/JsonFileTests.cs @@ -109,6 +109,19 @@ public void Should_BePossibleTo_GetEmptyValueDictionary() [NonParallelizable] public void Should_BePossibleTo_OverrideDictionaryOfValues_FromEnvVar() { + CheckOverrideDictionaryFromEnvVar(); + } + + [Test] + [NonParallelizable] + public void Should_BePossibleTo_OverrideDictionaryOfObjects_FromEnvVar() + { + CheckOverrideDictionaryFromEnvVar(); + } + + private void CheckOverrideDictionaryFromEnvVar() + { + var expectedDict = new Dictionary { {"intl.accept_languages", "1"}, @@ -120,7 +133,7 @@ public void Should_BePossibleTo_OverrideDictionaryOfValues_FromEnvVar() Environment.SetEnvironmentVariable("driverSettings.chrome.options.disable-popup-blocking", "bla"); Assert.AreEqual(expectedDict, - AddedParamsSettings.GetValueDictionary(".driverSettings.chrome.options"), + AddedParamsSettings.GetValueDictionary(".driverSettings.chrome.options"), "Dictionary of keys and values was overriden successively"); }