Capgemini.PowerApps.SpecFlowBindings 0.7.0-alpha

This is a prerelease version of Capgemini.PowerApps.SpecFlowBindings.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Capgemini.PowerApps.SpecFlowBindings --version 0.7.0-alpha
NuGet\Install-Package Capgemini.PowerApps.SpecFlowBindings -Version 0.7.0-alpha
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="Capgemini.PowerApps.SpecFlowBindings" Version="0.7.0-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Capgemini.PowerApps.SpecFlowBindings --version 0.7.0-alpha
#r "nuget: Capgemini.PowerApps.SpecFlowBindings, 0.7.0-alpha"
#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 Capgemini.PowerApps.SpecFlowBindings as a Cake Addin
#addin nuget:?package=Capgemini.PowerApps.SpecFlowBindings&version=0.7.0-alpha&prerelease

// Install Capgemini.PowerApps.SpecFlowBindings as a Cake Tool
#tool nuget:?package=Capgemini.PowerApps.SpecFlowBindings&version=0.7.0-alpha&prerelease

Power Apps SpecFlow Bindings

A SpecFlow bindings library for Power Apps.

The aim of this project is to make Power Apps test automation easier, faster and more accessible. It does this by providing a library of generic SpecFlow step bindings that adhere to test automation best practices. This allows effective automated tests to be written without the dependency on developers who are both proficient with Power Apps and test automation.

Table of Contents

  1. Installation
  2. Usage
  3. Contributing
  4. Credits
  5. Licence

Installation

Follow the guidance in the Installation and Setup section in https://specflow.org/getting-started/. After installing the IDE integration and setting up your project, install the NuGet package.

PM> Install-Package Capgemini.PowerApps.SpecFlowBindings

Once the NuGet package is installed, follow the SpecFlow documentation on referencing an external binding library. At the time of writing - for SpecFlow 3.x - you should update a specflow.json file in your project root as follows -

{
    "stepAssemblies": [
        { "assembly": "Capgemini.PowerApps.SpecFlowBindings" }
    ]
}

WebDrivers

We do not have a dependency on any specific WebDrivers. You will need to ensure that the correct WebDrivers are available in your project based on the browser that you are targetting. For example - if your configuration file is targetting Chrome - you can install the Chrome WebDriver via NuGet -

PM> Install-Package Selenium.Chrome.WebDriver

Usage

Configuration

Installing the NuGet package creates a power-apps-bindings.yml file in your project's root. This is used to configure the URL, browser, and users that will be used for your tests.

url: SPECFLOW_POWERAPPS_URL
browserOptions:
  browserType: Chrome
  headless: true
  width: 1920
  height: 1080
  startMaximized: false
users:
  - username: SPECFLOW_POWERAPPS_USERNAME_SALESPERSON
    password: SPECFLOW_POWERAPPS_PASSWORD_SALESPERSON
    alias: a salesperson

The URL, usernames, and passwords will be set from environment variable (if found). Otherwise, the value from the config file will be used. The browserOptions node supports anything in the EasyRepro BrowserOptions class.

Writing feature files

You can use the predefined step bindings to write your tests.

Scenario: User can create a new account
	Given I am logged in to the 'Sales Team Member' app as 'an admin'
	When I open the 'Accounts' sub area of the 'Customers' group
	Then I can see the 'New' command

Alternatively, write your own step bindings (see below).

Writing step bindings

You can write your own step bindings that have thread-safe access to EasyRepro and the Selenium WebDriver. This ensures that your tests can be ran safely in parallel. You can do this by creating a class decorated with the SpecFlow BindingAttribute and inheriting from the PowerAppsStepDefiner base class. You can then create your SpecFlow step bindings by interacting with the XrmApp and Driver properties.

[Binding]
public class MyCustomSteps : PowerAppsStepDefiner
{
    [Given(@"I have a custom step")]
    public void GivenIHaveACustomStep()
    {
      // Interact with the inherited EasyRepro 'Browser' object.
      // Interact with the inherited Selenium 'Driver' object.
    }
}

Test setup

We are avoiding performing test setup via the UI. This speeds up test execution and makes the tests more robust (as UI automation is more fragile than using supported APIs). Given steps should therefore be carried out using the Client API, WebAPI or Organization Service.

You can create test data by using the following Given step -

Given I have created "a record"

It will look for a JSON file in the data folder. You must ensure that these files are copying to the build output directory. You do not need to include the .json extension when writing the step (the example above would look for 'a record.json').

The JSON is the same as expected by WebAPI when creating records via a deep insert. The example below will create the following -

  • An account
  • An primary contact related to the account
  • An opportunity related to the account
  • A task related to the opportunity
{
  "@logicalName": "account",
  "@alias": "sample account",
  "name": "Sample Account",
  "primarycontactid": {
    "firstname": "John",
    "lastname": "Smith"
  },
  "opportunity_customer_accounts": [
    {
      "name": "Opportunity associated to Sample Account",
      "Opportunity_Tasks": [{ "subject": "Task associated to opportunity" }]
    }
  ]
}

The @logicalName property is required for the root record. @alias property can optionally be added to any record and allows the record to be referenced in certain bindings including the json for subsequent data creation steps per the example below:

Step 1 Given I have created "a contact"

{
  "@logicalName": "contact",
  "@alias": "sample contact",
  "firstname": "John",
  "lastname": "Smith"
}

Step 2 Given I have created "a account"

{
  "@logicalName": "account",
  "@alias": "sample account",
  "name": "Sample Account",
  "primarycontactid@alias.bind": "sample contact" 
}

Contributing

Ensure that your changes are thoroughly tested before creating a pull request. If applicable, update the UI test project within the tests folder to ensure coverage for your changes.

Licence

Power Apps SpecFlow Bindings is released under the MIT licence.

Product Compatible and additional computed target framework versions.
.NET Framework net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  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
0.14.13 68 4/17/2024
0.14.12 59 4/17/2024
0.14.12-bugfix-webdriver0005 105 4/16/2024
0.14.10 6,981 9/28/2022
0.14.7 374 9/20/2022
0.14.6 5,540 8/5/2022
0.14.5 364 8/4/2022
0.14.4-feat-2021-relea-0006 459 3/29/2022
0.14.4-feat-2021-relea-0005 168 3/23/2022
0.14.4-feat-2021-relea-0004 676 1/7/2022
0.14.4-feat-2021-relea-0003 1,510 10/20/2021
0.14.3 10,590 6/29/2021
0.14.2 318 6/25/2021
0.14.0 316 6/24/2021
0.13.5 321 6/8/2021
0.13.2 6,043 3/11/2021
0.13.1 615 2/24/2021
0.12.1 590 1/26/2021
0.12.0 322 1/16/2021
0.12.0-extend-data-file0009 232 1/15/2021
0.11.0 310 1/13/2021
0.10.6-test-data-setup-0008 242 1/12/2021
0.10.5 1,477 1/4/2021
0.10.3 562 11/19/2020
0.10.2 390 11/19/2020
0.10.1 473 11/18/2020
0.10.0 789 10/28/2020
0.9.15 554 10/25/2020
0.9.14 461 10/20/2020
0.9.13 443 10/20/2020
0.9.12 408 10/18/2020
0.9.7 594 10/11/2020
0.9.5 432 10/11/2020
0.9.1 385 10/9/2020
0.9.0 387 10/9/2020
0.7.1-alpha 469 9/16/2020
0.7.0-alpha 549 9/16/2020