VisionAutomationFramework 3.0.0-beta.1

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

3.0.0-beta.1 is a preview. In Visual Studio tick Include prerelease to see it; the stable release is 2.1.0. 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
  • 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.
  • This beta is tested with Chrome on Windows. Firefox, and Linux and macOS on .NET 10, are supported by design but not yet tested.

Installation

dotnet add package VisionAutomationFramework --prerelease

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.

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.
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-beta.1: .NET 10 alongside .NET Framework 4.7.2; no test framework dependency (failed checks throw VafAssertionException; works with NUnit 3 and 4, MSTest and xUnit); only Selenium as a dependency; settings from VAF_* environment variables or app.config. Breaking: BrowserStack, the mobile types, WinFormApplication and InternetExplorer are removed; the MSTest v1 screenshot overload is replaced by LetsSaveScreenshotTo. See "Migrating from 2.x" in the README.