VisionAutomationFramework 3.0.0

dotnet add package VisionAutomationFramework --version 3.0.0
                    
NuGet\Install-Package VisionAutomationFramework -Version 3.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="VisionAutomationFramework" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VisionAutomationFramework" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="VisionAutomationFramework" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VisionAutomationFramework --version 3.0.0
                    
#r "nuget: VisionAutomationFramework, 3.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.
#:package VisionAutomationFramework@3.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VisionAutomationFramework&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=VisionAutomationFramework&version=3.0.0
                    
Install as a Cake Tool

Vision Automation Framework (VAF)

VAF is a fluent test automation framework for .NET on top of Selenium WebDriver. Waiting for the page, for elements to be visible and interactable is handled for you, so tests read like the steps they describe.

Upgrading from 2.x: see Migrating from 2.x.

Requirements

  • A test project for .NET Framework 4.7.2 (or newer 4.x) or .NET 10. .NET 8 and 9 are not supported: the build stops with error VAF0001.
  • Any test framework: NUnit 3 or 4, MSTest, xUnit. VAF does not depend on one.
  • Google Chrome, Firefox, or Safari on macOS. Selenium Manager downloads the matching browser driver on the first run, no driver package needed.
  • Tested with Chrome and Firefox on Windows. Linux and macOS on .NET 10 are supported by design but not yet tested.

Installation

dotnet add package VisionAutomationFramework
  • NuGet picks the lowest Selenium VAF allows (4.45.0). For a newer one, add Selenium.WebDriver and Selenium.Support to your project yourself, both with the same version; VAF works with any 4.x from 4.45.
  • In an old-style project (packages.config), install through Manage NuGet Packages, so the references to Selenium.WebDriver and Selenium.Support are added too; a hand-written HintPath to VAF alone does not bring them.

Quick start

using NUnit.Framework;
using VisionAutomationFramework;
using VisionAutomationFramework.Browsers;
using VisionAutomationFramework.Extensions;

public class Tests
{
    [Test]
    public void OpensExampleDomain()
    {
        var browser = Testing.On<Chrome>();

        try
        {
            browser.LetsNavigateTo("https://example.com/")
                .Should().HaveTitle("Example Domain");
        }
        finally
        {
            browser.Scope.Driver.Quit();
        }
    }
}

With MSTest or xUnit the test is the same, only the attributes differ ([TestMethod], [Fact]). A failed check throws VafAssertionException, which every test framework reports as a failed test:

VisionAutomationFramework.VafAssertionException : Title on active tab isn't correctly populated
  Expected: "Wrong title"
  But was:  "Example Domain"

The full guide is at https://www.visionautomationframework.com/quick-start-guide.

Settings

Each setting is read from the environment variable VAF_<name> first, then from appSettings in the test project's app.config. Environment variables also work on .NET 10, where app.config often does not reach the test run, and in CI.

Setting Default Meaning
ElementWaitTimeout 10 Seconds to wait for an element
LoaderWaitTimeout 60 Seconds to wait for a loader to disappear
DownloadDirectory c:\mydownloads on Windows, <temp>/vaf-downloads elsewhere Where Chrome and Firefox save downloads

What's new in 3.0

  • .NET 10 alongside .NET Framework 4.7.2, with the same API.
  • No test framework dependency. Works with NUnit 3 and 4, MSTest and xUnit. Under MSTest the TestExecutionContext.IsolatedContext workaround is no longer needed.
  • Only Selenium as a dependency (Selenium.WebDriver and Selenium.Support 4.45 or newer 4.x; on .NET 10 also System.Configuration.ConfigurationManager, for app.config).
  • Settings from environment variables (VAF_ElementWaitTimeout, …) or app.config, and a new DownloadDirectory setting.
  • LetsSaveScreenshotTo(directory, fileName) saves a screenshot anywhere and returns the path, so you can attach it in any test framework. LetsTakeScreenshot() still saves it in the NUnit test directory and attaches it to the NUnit result.
  • LetsSelectOptionFromRightClickMenu refuses to send keys when the browser is not the foreground window, instead of typing into another window. Do not run such tests in parallel. Firefox started from a test run usually does not get the foreground on Windows, so with Firefox this method mostly refuses; it works with Chrome.
  • Testing.On(browser) for a browser you create with settings, e.g. a remote grid or extra arguments: Testing.On(new MyRemoteChrome(gridUrl)). Testing.On<Chrome>() stays for browsers without settings.
  • AndAlso() also after a check, so several checks on one section stay in one chain: .AsLabelText().Should().HaveValue("…").AndAlso().Should().HaveElement<Next>()…
  • HTML reports are named VAF_Log_<test name>_<yyyy-MM-dd_HH-mm-ss>.html, so tests that finish in the same minute no longer overwrite each other's report (2.x: VAF_Log_<hh-mm MM-dd-yyyy>.html).

Migrating from 2.x

Most tests recompile unchanged. Check these points:

2.x 3.0
VAF brought NUnit, Newtonsoft.Json and RestSharp into your project Only Selenium. If your tests use NUnit, Newtonsoft.Json or RestSharp, reference them yourself.
Failed checks threw NUnit's AssertionException They throw VisionAutomationFramework.VafAssertionException. Change catch (AssertionException) in your code.
LetsTakeScreenshot(TestContext tc, …) with the MSTest v1 TestContext var path = browser.LetsSaveScreenshotTo(TestContext.TestResultsDirectory); then TestContext.AddResultFile(path);
BrowserStack: Testing.On<T>(browserStackOptions), BrowserStackRemoteWebDriver, BrowserStackExtensions, IOSSafari, MobileRemoteDriver, MobileDevice Removed (obsolete since 2.1). For a remote grid, implement IBrowserDefinition returning a Selenium RemoteWebDriver, and start it with Testing.On(new YourRemoteBrowser(options)).
Mobile types: MobileAppActions, MobileAppAssertions, ActionsMobileApp<T>, AppScope, IMobileContext, MobileApp, non-generic ButtonActions / ButtonAssertions Removed. They could not be used: there was no way to start a mobile session.
WinFormApplication, InternetExplorer Removed (the first was never implemented; Internet Explorer is retired).
WebElementAssertionMethods in the global namespace In VisionAutomationFramework.Extensions.
MSTest: new NUnit.Framework.Internal.TestExecutionContext.IsolatedContext(); in [TestInitialize] Not needed; remove it.

Features

  • Chrome, Firefox and Safari; your own browsers through IBrowserDefinition
  • Pages, sections and elements as small classes with one locator each
  • Element-specific actions and assertions (AsButton(), AsTextInputField(), AsLabelText(), …)
  • Built-in waits and loader handling
  • XML test log with an HTML report

Contact

https://www.visionautomationframework.com/contact

License

MIT — see LICENSE.md.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Framework net472 is compatible.  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.

3.0.0: .NET 10 alongside .NET Framework 4.7.2, with the same API. No test framework dependency: failed checks throw VafAssertionException, which NUnit 3 and 4, MSTest and xUnit report as a failed test. Only Selenium as a dependency. Settings from VAF_* environment variables or app.config. New: Testing.On(browser) for a browser created with settings (remote grid, extra arguments); LetsSaveScreenshotTo; AndAlso() also after a check; HTML report named per test; a .NET 5-9 project stops at build with error VAF0001. Removed: BrowserStack, the mobile types, WinFormApplication, InternetExplorer and the MSTest v1 screenshot overload. Upgrading from 2.x: see "Migrating from 2.x" in the README.