![]() |
VOOZH | about |
dotnet add package Futile.Specflow.Actions.FlaUI --version 1.0.4
NuGet\Install-Package Futile.Specflow.Actions.FlaUI -Version 1.0.4
<PackageReference Include="Futile.Specflow.Actions.FlaUI" Version="1.0.4" />
<PackageVersion Include="Futile.Specflow.Actions.FlaUI" Version="1.0.4" />Directory.Packages.props
<PackageReference Include="Futile.Specflow.Actions.FlaUI" />Project file
paket add Futile.Specflow.Actions.FlaUI --version 1.0.4
#r "nuget: Futile.Specflow.Actions.FlaUI, 1.0.4"
#:package Futile.Specflow.Actions.FlaUI@1.0.4
#addin nuget:?package=Futile.Specflow.Actions.FlaUI&version=1.0.4Install as a Cake Addin
#tool nuget:?package=Futile.Specflow.Actions.FlaUI&version=1.0.4Install as a Cake Tool
This SpecFlow.Action will help you use FlaUI together with SpecFlow.
Work on Specflow has been discontinued and the successor is reqnroll. This nuget package is an addition to a fork.
specflow.actions.jsonYou can configure this plugin via the specflow.actions.json.
{
"flaui": {
"settings": {
"uia": "UIA2"
},
"profiles": {
"Calculator.exe with Hello FlaUI": {
"app": "[path]\Calculator.exe",
"arguments": "Hello FlaUI",
"launch": "Exe"
},
"Windows 11 Calculator": {
"app": "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App",
"launch": "StoreApp"
}
}
}
}
Supported values:
UIA2UIA3filename of the executable or the name of the Windows App. The Windows App names can be found in folder %userprofile%\AppData\Local\Packages.
Optional list of arguments.
Supported values:
ExeStoreAppThe application is started automatically when you try to use it for the first time. It is closed after the scenario ends. You can use constructor and/or parameter injection to inject dependencies into your classes, this way the class instances are managed automatically.
Wraps the FlaUI access to the application.
public class CalculatorMainWindowElements
{
private readonly FlaUIDriver _driver;
public CalculatorMainWindowElements(FlaUIDriver driver)
{
_driver = driver;
}
public TextBox FirstNumberTextBox => _driver.Current.FindFirstDescendant("TextBoxFirst").AsTextBox();
public TextBox SecondNumberTextBox => _driver.Current.FindFirstDescendant("TextBoxSecond").AsTextBox();
public TextBox ResultTextBox => _driver.Current.FindFirstDescendant("TextBoxResult").AsTextBox();
public Button AddButton => _driver.Current.FindFirstDescendant("ButtonAdd").AsButton();
}
Represents the application under test.
public class CalculatorProxy
{
private readonly FlaUIDriver _driver;
private readonly CalculatorMainWindowElements _elements;
public CalculatorProxy(FlaUIDriver driver)
{
_driver = driver;
_elements = new CalculatorMainWindowElements(driver);
}
public void EnterFirstNumber(string number)
{
_elements.FirstNumberTextBox.Text += number;
}
public void EnterSecondNumber(string number)
{
_elements.SecondNumberTextBox.Text += number;
}
public void ClickAdd()
{
_elements.AddButton.Click();
}
public string GetResult()
{
return _elements.ResultTextBox.Text;
}
}
[Binding]
public sealed class CalculatorStepDefinitions
{
private readonly CalculatorProxy _proxy;
public CalculatorStepDefinitions(CalculatorProxy proxy)
{
_proxy = proxy;
}
[Given("the first number is (.*)")]
public void GivenTheFirstNumberIs(int number)
{
_proxy.EnterFirstNumber(number.ToString());
}
}
FlaUIDriver.Current returns the automation element of the application's main window. Some common operations to get descendants or children without automation id are "ByName" or "ByClassName":
var okButton = _driver.Current.FindFirstDescendant(_driver.Get.ByName("OK"));var otherWindow = _driver.Current.FindFirstDescendant(_driver.Get.ByClassName("Configuration"));Examples can be found on the FlaUI website.
The class AppiumLikeInteractions is for convenience if you are familiar with Appium or if you migrate a project based on the SpecFlow.Actions.WindowsAppDriver .
public class CalculatorMainWindowElements
{
private readonly AppiumLikeInteractions _interactions;
public CalculatorMainWindowElements(FlaUIDriver driver)
{
_interactions = new AppiumLikeInteractions(driver);
}
public TextBox FirstNumberTextBox => _interactions.FindElementByAccessibilityId("TextBoxFirst").AsTextBox();
public TextBox SecondNumberTextBox => _interactions.FindElementByAccessibilityId("TextBoxSecond").AsTextBox();
public TextBox ResultTextBox => _interactions.FindElementByAccessibilityId("TextBoxResult").AsTextBox();
public Button AddButton => _interactions.FindElementByAccessibilityId("ButtonAdd").AsButton();
}
The class
CalculatorMainWindowElementsfrom the example above with Appium-like interactions
Add the latest version of the Futile.SpecFlow.Actions.FlaUI NuGet Package to your project.
Latest version: 👁 Nuget
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 net8.0-windows7.0 is compatible. net9.0-windows net9.0-windows was computed. net10.0-windows net10.0-windows was computed. |
| .NET Framework | net481 net481 is compatible. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.