Futile.SpecFlow.Actions.WindowsAppDriver
0.1.350.7
dotnet add package Futile.SpecFlow.Actions.WindowsAppDriver --version 0.1.350.7
NuGet\Install-Package Futile.SpecFlow.Actions.WindowsAppDriver -Version 0.1.350.7
<PackageReference Include="Futile.SpecFlow.Actions.WindowsAppDriver" Version="0.1.350.7" />
paket add Futile.SpecFlow.Actions.WindowsAppDriver --version 0.1.350.7
#r "nuget: Futile.SpecFlow.Actions.WindowsAppDriver, 0.1.350.7"
// Install Futile.SpecFlow.Actions.WindowsAppDriver as a Cake Addin #addin nuget:?package=Futile.SpecFlow.Actions.WindowsAppDriver&version=0.1.350.7 // Install Futile.SpecFlow.Actions.WindowsAppDriver as a Cake Tool #tool nuget:?package=Futile.SpecFlow.Actions.WindowsAppDriver&version=0.1.350.7
Futile.SpecFlow.Actions.WindowsAppDriver
This SpecFlow.Action will help you use Windows App Driver together with SpecFlow. It handles the lifetime of the Windows App Driver, and the Appium instance created to interact with the application.
Futile?
Work on Specflow has been discontinued and the successor is reqnroll (status May 2024). This nuget package comes from a fork that:
- Includes some bug fixes
- Uses
net48
andnet6.0
Updated examples can be found here: Futile.SpecFlow-Examples.
Prerequisites
- Install Windows App Driver
- Enable Developer Mode in Windows settings
Included Features
- Lifetime handling of Windows App Driver and the application being tested
- Configuration via
specflow.actions.json
- Automatic screenshot capture
Configuration
You can configure this plugin by adding a json file into your project named specflow.actions.json
. Set the file as 'content' and to 'copy if newer'.
Example:
{
"windowsAppDriver": {
"capabilities": {
"app": "../SpecFlowCalculator/bin/Debug/net5.0-windows/SpecFlowCalculator.exe"
},
"WindowsAppDriverPath": "C:/Program Files/Windows Application Driver/WinAppDriver.exe",
"WindowsAppDriverPort": 4723,
"EnableScreenshots": true,
"CloseAppAutomatically": false
}
}
windowsAppDriver.capabilities
- The capabilities used to configure the appium instance. In this case, we have provided the path to the WinForms application being tested (path is combined with the current directory, so you must take this into consideration)if (string.Equals(capability.Key, "app", StringComparison.OrdinalIgnoreCase)) { options.AddAdditionalCapability(capability.Key, Path.Combine(Directory.GetCurrentDirectory(), capability.Value)); }
WindowsAppDriverPath
- The path to the Windows App Driver CLI (must be absolute, not relative)EnableScreenshots
- If no value is provided, then this resolves to false. If you want to enable screenshots, then set the value to true. Screenshots will be taken after each step automatically using the following folder structure:\TestResults\Screenshots\{yyyy-MM-dd_Hmmss}\{Feature title}\{Scenario title}\{Step name} ({execution status}).png
e.g.\TestResults\Screenshots\2021-10-11_171822\Calculator\Add two numbers\the first number is 50 (OK).png
WindowsAppDriverPort
- If specified, the Windows App Driver will be launched using this port. If not specified, the default port 4723 will be used. (This setting is useful, if the default port is already in use by another application.)CloseAppAutomatically
- This setting is optional and defaults totrue
. Iffalse
, the app will not be closed automatically after each scenario.
Important information
If you do not provide these configuration values, then the next default fallback is to check for the following environment variables:
Environment.GetEnvironmentVariable("TEST_SUBJECT_FILE_PATH");
Environment.GetEnvironmentVariable("WINDOWS_APP_DRIVER_EXECUTABLE_PATH")
The path to the test subject is required either from the configuration value, or the environment variable.
The path to the Windows App Drive CLI is not required, so if the configuration value and the environment variable returns null
then the Windows App Drive CLI wont launch. This gives you the oppertunity for the Windows App Driver CLI to be handled via a CI/CD pipeline instead of having to manually install it on the agent.
How to use it
Inject the
AppDriver
class into your consuming class using constructor/parameter injection inside of your test project. This will give you access to the current instance of the AppDriver. The lifetime of this object is handled and disposed once no longer required.public class CalculatorFormElements { private readonly AppDriver _appDriver; public CalculatorFormElements(AppDriver appDriver) { _appDriver = appDriver; } public WindowsElement FirstNumberTextBox => _appDriver.Current.FindElementByAccessibilityId("textBox_firstNumber"); public WindowsElement SecondNumberTextBox => _appDriver.Current.FindElementByAccessibilityId("textBox_secondNumber"); public WindowsElement AddButton => _appDriver.Current.FindElementByAccessibilityId("button_add"); public WindowsElement SubtractButton => _appDriver.Current.FindElementByAccessibilityId("button_subtract"); public WindowsElement MultiplyButton => _appDriver.Current.FindElementByAccessibilityId("button_multiply"); public WindowsElement DivideButton => _appDriver.Current.FindElementByAccessibilityId("button_divide"); public WindowsElement ResultTextBox => _appDriver.Current.FindElementByAccessibilityId("textBox_result"); }
The handling of the
AppDriverCli
class is abstracted away inside the plugin, so there is no need for you to do anything here. If you do not need the plugin to handle the Windows App Driver CLI, then do not provide the path in the configuration or the environment variable demonstrated below.public void Start() { var path = _windowsAppDriverConfiguration.WindowsAppDriverPath ?? Environment.GetEnvironmentVariable("WINDOWS_APP_DRIVER_EXECUTABLE_PATH") ?? null; if (path != null) { _appDriverProcess = Process.Start(path); } }
How to get it
Add the latest version of the Futile.SpecFlow.Actions.WindowsAppDriver
NuGet Package to your project.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- Appium.WebDriver (>= 4.4.5)
- Futile.SpecFlow.Actions.Appium (>= 0.1.350.7)
- Futile.SpecFlow.Actions.Configuration (>= 0.1.350.7)
- SpecFlow (>= 3.9.74)
-
net6.0
- Appium.WebDriver (>= 4.4.5)
- Futile.SpecFlow.Actions.Appium (>= 0.1.350.7)
- Futile.SpecFlow.Actions.Configuration (>= 0.1.350.7)
- SpecFlow (>= 3.9.74)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.