WebViewDriver.Host 0.3.0

dotnet add package WebViewDriver.Host --version 0.3.0
                    
NuGet\Install-Package WebViewDriver.Host -Version 0.3.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="WebViewDriver.Host" Version="0.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WebViewDriver.Host" Version="0.3.0" />
                    
Directory.Packages.props
<PackageReference Include="WebViewDriver.Host" />
                    
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 WebViewDriver.Host --version 0.3.0
                    
#r "nuget: WebViewDriver.Host, 0.3.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 WebViewDriver.Host@0.3.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=WebViewDriver.Host&version=0.3.0
                    
Install as a Cake Addin
#tool nuget:?package=WebViewDriver.Host&version=0.3.0
                    
Install as a Cake Tool

WebViewDriver.Host

This is the app-side package for WebViewDriver. It exposes an embedded webview to tests through a local JavaScript evaluation endpoint.

Install this package in the app under test. Install WebViewDriver.Selenium in the test project.

Setup

Register the host and attach the webview after its platform view is created:

using Microsoft.Maui.Handlers;
using WebViewDriver.Host;

#if DEBUG
WebViewDriverHost.TryStartFromEnvironment();

HybridWebViewHandler.Mapper.AppendToMapping("WebViewDriver", (handler, _) =>
{
#if MACCATALYST || IOS
    WebViewDriverHost.Attach(
        "main",
        (WebKit.WKWebView)handler.PlatformView);
#endif
});
#endif

Custom webview wrappers can provide an evaluation delegate:

WebViewDriverHost.Attach(
    "main",
    script => myWebView.EvaluateJavaScriptAsync(script));

The test launcher must set both environment variables:

WEBVIEWDRIVER_PORT=17321
WEBVIEWDRIVER_TOKEN=<random per-run token>

The host remains inactive when either value is missing.

Readiness

An app can prevent clients from connecting before startup is complete:

WebViewDriverHost.SetReady("main", false);
// Finish application startup.
WebViewDriverHost.SetReady("main", true);

Security

This package provides JavaScript evaluation inside the app. Include and register it only in Debug or QA builds.

  • The endpoint listens on 127.0.0.1 only.
  • Every request requires the session token.
  • Requests are size-limited.
  • Evaluations are serialized per webview.
  • No shell, file-system, or reflection API is exposed.

See the project documentation for the complete setup and supported commands.

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-ios26.0 is compatible.  net10.0-maccatalyst was computed.  net10.0-maccatalyst26.0 is compatible.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net10.0-ios26.0

    • No dependencies.
  • net10.0-maccatalyst26.0

    • No dependencies.

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.3.0 103 9/18/2026

Initial 0.3 release.