Futile.Specflow.Actions.FlaUI 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Futile.Specflow.Actions.FlaUI --version 1.0.0                
NuGet\Install-Package Futile.Specflow.Actions.FlaUI -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Futile.Specflow.Actions.FlaUI" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Futile.Specflow.Actions.FlaUI --version 1.0.0                
#r "nuget: Futile.Specflow.Actions.FlaUI, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Futile.Specflow.Actions.FlaUI as a Cake Addin
#addin nuget:?package=Futile.Specflow.Actions.FlaUI&version=1.0.0

// Install Futile.Specflow.Actions.FlaUI as a Cake Tool
#tool nuget:?package=Futile.Specflow.Actions.FlaUI&version=1.0.0                

Futile.SpecFlow.Actions.FlaUI

Nuget

This SpecFlow.Action will help you use FlaUI together with SpecFlow.

Futile?

Work on Specflow has been discontinued and the successor is reqnroll (status May 2024). This nuget package is an addition to a fork.

Included Features

  • Lifetime handling of the application being tested
  • Configuration via specflow.actions.json
  • Launch of executables and Windows Store Apps (e.g. Calculator)

Configuration

You 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"
      }
    }
  }
}

uia

Supported values:

  • UIA2
  • UIA3

app

filename of the executable or the name of the Windows App. The Windows App names can be found in can be found as folder in %userprofile%\AppData\Local\Packages.

arguments

Optional list of arguments.

launch

Supported values:

  • Exe
  • StoreApp

How to use it

The 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.

Elements object

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();
}

Proxy object

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;
  }
}

Step definitions

[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());
  }
}

How to get it

Add the latest version of the Futile.SpecFlow.Actions.FlaUI NuGet Package to your project.

Latest version: Nuget

Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net8.0-windows was computed. 
.NET Framework net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 100 9/19/2024
1.0.2 129 9/14/2024
1.0.1 124 6/10/2024
1.0.0 111 6/1/2024