Skip to main content
All docs
V24.2
.NET Framework 4.6.2+

Integrate EasyTest to XAF ASP.NET Web Forms Applications

  • 4 minutes to read

Overview

XAF can run functional tests for ASP.NET Web Forms applications based on the Selenium driver to interact with browser.

EasyTest for ASP.NET Web Forms supports the following browsers:

  • Google Chrome
  • Microsoft Edge

This topic describes how to integrate EasyTest functional testing to your XAF ASP.NET WebForms application.

Prerequisites

Configure your working machine as described below:

  1. Install browser drivers.

    Selenium requires a path to the downloaded driver. You can specify a path to the driver in any of the following ways:

    • Add a folder with the driver to the system’s PATH variable.
    • Specify a path to the driver in EasyTest’s configuration file.

      <Application ... WebDriverPath="C:\WebDriverPath" />
      
  2. Install the DevExpress.ExpressApp.EasyTest.SeleniumWebAdapter package to your YourApplicationName.Web project.

Configuration

The code below demonstrates a sample configuration file. You can edit it according to your project environment.

<?xml version="1.0" encoding="utf-8" ?> 
<Options xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
    <Applications> 
        <!-- ASP.NET Web Forms --> 
        <Application 
            Name="DXApplication1Web"
            UseIISExpress="True"
            Url="http://localhost:4030" 
            PhysicalPath="[WebAppBin]" 
            AdapterFileName="[WebAdapterAssemblyPath]" 
            Configuration="EasyTest" 
            IgnoreCase="true"/> 
    </Applications> 

    <TestDatabases> 
            <Database xsi:type="TestMSSQLDatabase" Server="(localdb)\mssqllocaldb" DBName="DXApplication1EasyTest"/> 
    </TestDatabases> 

    <Aliases> 
        <Alias Name="WebAppBin" Value="[ConfigPath]\..\..\DXApplication1.Web" /> 
        <Alias Name="WebAdapterAssemblyPath" Value="[WebAppBin]\Bin\DevExpress.ExpressApp.EasyTest.SeleniumWebAdapter.v21.2.dll" />
    </Aliases> 
</Options> 

Configuration Options

Attribute Description
Name Specifies the name of the Application element. This name is used to differentiate between different applications. The Application command takes this name as the parameter.
Url The application’s web address.
PhysicalPath A path to the folder that contains the application. You can use the built-in [ConfigPath] alias to specify a path to the Config.xml file.
AdapterAssemblyName Specifies the name of the ASP.NET Web Forms EasyTest adapter. This is an EasyTest assembly that contains platform-specific functionality. The attribute contains the adapter’s assembly filename, assembly version, culture, and public key.
IgnoreCase Specifies whether the test ignores a letter case when referring to UI element names, captions, or tags.
UseIISExpress Specifies whether the IIS Express is used to run the application. If set to false, WebDev is used instead.
Configuration Specifies the configuration to use when running tests.
WebDriverPath Specifies a path to a folder that stores a web driver executable.
Browser Specifies a web browser to use for running tests. Available values: Chrome, Edge (the default value).

Aliases

Alias Description
WebAppBin A path to an ASP.NET Web Forms application.
WebAdapterAssemblyPath A path to the ASP.NET Web Forms EasyTest adapter. This path is typically points to a project’s build results. Reference the DevExpress.ExpressApp.EasyTest.SeleniumWebAdapter adapter and it becomes available in the project’s build results.

Run EasyTest in the Debug Configuration

The following steps describe the modifications required to support EasyTest in the Debug solution configuration.

Note that after updating the solution in this way, EasyTest will use database connection strings specified in the application projects’ configuration files. So you may want to backup the databases used by the applications before running any actual tests.

In an ASP.NET Web Forms application project, the following methods must be updated.

  1. The DatabaseVersionMismatch method in the WebApplication.cs (WebApplication.vb) file.

    private void MySolutionAspNetApplication_DatabaseVersionMismatch(
        object sender, DevExpress.ExpressApp.DatabaseVersionMismatchEventArgs e) {
    #if DEBUG
        e.Updater.Update();
        e.Handled = true;
    #else
        if (System.Diagnostics.Debugger.IsAttached) {
            //...
        }
        else {
            //...
        }
    #endif
    }
    
  2. The Application_Start method in the Global.asax.cs (Global.asax.vb) file.

    protected void Application_Start(Object sender, EventArgs e) {
        WebApplication.OldStyleLayout = false;
    
    #if DEBUG
        DevExpress.ExpressApp.Web.TestScripts.TestScriptsManager.EasyTestEnabled = true;
    #endif
    }
    

Remove EasyTest

You can remove all EasyTest components from your application. In this case, delete the following:

  • The FunctionalTests folder.
  • The DevExpress.ExpressApp.EasyTest.SeleniumWebAdapter package.
  • The EASYTEST conditions from the ASP.NET Web Forms application project’s Global.asax.cs (Global.asax.vb) and WebApplication.cs (WebApplication.vb) files.

Next Steps