Skip to content

Commit

Permalink
Update Aquality.Selenium.Core version (#50)
Browse files Browse the repository at this point in the history
Support overriding of capabilities from environment variables
Support FindChildElements feature
  • Loading branch information
mialeska authored Jun 8, 2020
1 parent 480a0fa commit 61da6f4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public override IServiceCollection ConfigureServices(IServiceCollection services
base.ConfigureServices(services, applicationProvider, settings);
services.AddTransient<IElementFactory, ElementFactory>();
services.AddTransient<CoreElementFactory, ElementFactory>();
services.AddSingleton<IDriverSettings>(serviceProvider => new DriverSettings(settings));
services.AddSingleton<IApplicationProfile>(serviceProvider => new ApplicationProfile(settings, serviceProvider.GetRequiredService<IDriverSettings>()));
services.AddSingleton<IDriverSettings, DriverSettings>();
services.AddSingleton<IApplicationProfile, ApplicationProfile>();
services.AddSingleton<ILocalizationManager>(serviceProvider => new LocalizationManager(serviceProvider.GetRequiredService<ILoggerConfiguration>(), serviceProvider.GetRequiredService<Logger>(), Assembly.GetExecutingAssembly()));
services.AddSingleton<IKeyboardActions>(serviceProvider => new KeyboardActions(serviceProvider.GetRequiredService<ILocalizedLogger>(), () => AqualityServices.Application.Driver));
services.AddSingleton<IMouseActions>(serviceProvider => new MouseActions(serviceProvider.GetRequiredService<ILocalizedLogger>(), () => AqualityServices.Application.Driver));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

<ItemGroup>
<PackageReference Include="Appium.WebDriver" Version="4.1.1" />
<PackageReference Include="Aquality.Selenium.Core" Version="1.0.0" />
<PackageReference Include="Aquality.Selenium.Core" Version="1.1.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,47 @@ public class DriverSettings : IDriverSettings
private const string ApplicationPathJPath = DriverSettingsPath + ".applicationPath";
private const string AppCapabilityKey = "app";

private readonly ISettingsFile settingsFile;

/// <summary>
/// Instantiates class using JSON file with general settings.
/// </summary>
/// <param name="settingsFile">JSON settings file.</param>
public DriverSettings(ISettingsFile settingsFile)
{
SettingsFile = settingsFile;
this.settingsFile = settingsFile;
}

protected ISettingsFile SettingsFile { get; }

protected IDictionary<string, object> Capabilities => SettingsFile.GetValueOrNew<Dictionary<string, object>>($"{DriverSettingsPath}.capabilities");

protected virtual IDictionary<string, object> Capabilities => settingsFile.GetValueOrNew<Dictionary<string, object>>($"{DriverSettingsPath}.capabilities");

/// <summary>
/// Defines does the current settings have the application path defined
/// </summary>
protected bool HasApplicationPath => SettingsFile.IsValuePresent(ApplicationPathJPath);
protected virtual bool HasApplicationPath => settingsFile.IsValuePresent(ApplicationPathJPath) || Capabilities.ContainsKey(AppCapabilityKey);

public AppiumOptions AppiumOptions

public virtual AppiumOptions AppiumOptions
{
get
{
var options = new AppiumOptions();
Capabilities.ToList().ForEach(capability => options.AddAdditionalCapability(capability.Key, capability.Value));
if (HasApplicationPath)
if (HasApplicationPath && ApplicationPath != null)
{
options.AddAdditionalCapability(AppCapabilityKey, ApplicationPath);
}
return options;
}
}

public string ApplicationPath => Path.GetFullPath(SettingsFile.GetValue<string>(ApplicationPathJPath));
public virtual string ApplicationPath
{
get
{
var appValue = settingsFile.GetValueOrDefault(ApplicationPathJPath,
defaultValue: (Capabilities.ContainsKey(AppCapabilityKey) ? Capabilities[AppCapabilityKey] : null)?.ToString());
return appValue?.StartsWith(".") == true ? Path.GetFullPath(appValue) : appValue;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"isRemote": true,
"remoteConnectionUrl": "http://127.0.0.1:4723/",
"driverSettings": {
"applicationPath": "./Resources/Applications/Day Maxi Calc.exe",
"capabilities": {
"app": "./Resources/Applications/Day Maxi Calc.exe",
"platformVersion": "10",
"platformName": "Windows",
"deviceName": "WindowsPC",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"isRemote": true,
"remoteConnectionUrl": "http://127.0.0.1:4723/",
"driverSettings": {
"applicationPath": "./Resources/Applications/Day Maxi Calc.exe",
"capabilities": {
"app": "./Resources/Applications/Day Maxi Calc.exe",
"platformVersion": "10",
"platformName": "Windows",
"deviceName": "WindowsPC",
Expand Down

0 comments on commit 61da6f4

Please sign in to comment.